home *** CD-ROM | disk | FTP | other *** search
/ The Complete Utilities To…ka 501 Killer Utilities! / 501 Killer Utilities! (Macworld July 1995).cdr / Programming / Tools Plus 2.5.3 Evaluation Kit / Tools Plus 2.5.3 / Demos / Demo for THINK Pascal / Demo.p next >
Encoding:
Text File  |  1994-12-12  |  152.3 KB  |  2,383 lines  |  [TEXT/PJMM]

  1. {    Tools Plus    --    D e m o   P r o g r a m    --    (Version 2.5.3)                                                        }
  2. {    Copyright (c) 1994-95 Water's Edge Software                                                                    }
  3. {    Designed and programmed by Steve Makohin                                                                    }
  4.  
  5. {    All files in this project use the Helvetica font (9pt).                                                                }
  6. {    This application is written as a single source file (ie: I deliberately did NOT split it into units) to simplify            }
  7. {    compiling for programmers that are just starting out.  It also demonstrates that programming with Tools Plus        }
  8. {    makes source code compact and readable.                                                                        }
  9. {                                                                                                                    }
  10. {    If you are put off by the size of this program, please note that it is H E A V I L Y   C O M M E N T E D and it is not    }
  11. {    optimized, both of which were done to facilitate the teaching of Tools Plus.                                        }
  12. {                                                                                                                    }
  13. {    Though you will likely be able to figure out what each line of source code does, extensive comments are            }
  14. {    provided so you won't have to constantly refer to the Tools Plus User Manual and Inside Macintosh.                }
  15.  
  16.  
  17. {    G e t t i n g   S o m e w h e r e   F a s t :                                                                            }
  18. {    To view a list of routines found in this demo, hold the Command key down while clicking in this window's title bar.    }
  19. {    A pop-down menu is displayed showing you the routines' names. You can use this pop-down menu to quickly go    }
  20. {    to a specific routine.                                                                                            }
  21.  
  22.  
  23. {    R e s o u r c e s :                                                                                                }
  24. {    This demo uses resources that can be found in the 'Demo Resources' file.  The following describes each of the    }
  25. {    resources and what function they perform in this application.  You can add, change, delete and view resources    }
  26. {    by using a resource editor application such as Apple's ResEdit.                                                    }
  27. {                                                                                                                    }
  28. {    Type        ID        Description                                                                                    }
  29. {    ------    -----------    ----------------                                                                                }
  30. {    acur        128        Animated Cursor definition:  Tells Tools Plus how to animate the cursor to create a wrist        }
  31. {                        watch with a spinning second hand.  The 'acur' resource specifies the sequence of cursor    }
  32. {                        resources ('CURS') that will be used for the animation, and the time taken between steps.    }
  33. {                        See the User Manual for details.                                                            }
  34. {                                                                                                                    }
  35. {    BNDL        128        Bundle Resource:  This resource tells the Finder which icons are used to depict the            }
  36. {                        application and the documents created by it.  The BNDL resource bundles the following        }
  37. {                        related resources: FREF, icl4, icl8, ICN#, and 'TP 1'                                            }
  38. {                                                                                                                    }
  39. {    cicn        - -        Color Icons (definable size):  This is the first color icon format available on color (Mac II)        }
  40. {                        Macintoshes.  Each 'cicn' includes a color image, the equivalent black and white image, and    }
  41. {                        a mask.  In this demo, all 'cicn' icons were created using 4-bit colors to ensure that they        }
  42. {                        look good when displayed on monitors set to 16-colors/grays or higher.                        }
  43. {            300-303    These color icons (hard disk, floppy, and folder) show up in the Pop-Up Menus demo beside    }
  44. {                        menu item names.                                                                            }
  45. {            304,305    These 'large' color icons (printer and modem) appear in 'picture Pop-Up Menus' (picture in a    }
  46. {                        Pop-Up Menu without any text).  There are 'ICON' equivalents for these items for Macs        }
  47. {                        without Color QuickDraw.                                                                    }
  48. {            430-441    These "tape deck" buttons are used in the Picture Buttons demo to show you the look you    }
  49. {                        can get with Tools Plus's buttons.  Each button requires two icons, one for the button's        }
  50. {                        normal state, and one for the selected (pushed in) state.  I know, they don't behave like a    }
  51. {                        real tape deck, but this is only a demo.                                                        }
  52. {            460,461    This bi-directional "globe" button is used in the Picture Buttons demo.  The two icons show    }
  53. {                        the button in its normal state, and in its selected (pushed in) state.                            }
  54. {            464,465    This "Done" button is used in the Picture Buttons demo.  The two icons show the button in    }
  55. {                        its normal state, and in its selected (pushed in) state.  Even the most ordinary buttons can    }
  56. {                        look sophisticated with Tools Plus.                                                            }
  57. {            520-541    These are all used in the Floating Palettes demo to create clickable icons.  You can create    }
  58. {                        professional looking palettes with various styles of buttons using Tools Plus.                }
  59. {                                                                                                                    }
  60. {    CURS    128-134    Cursors:  These cursors are used to produce an animated cursor.  The 'acur' resource        }
  61. {                        specified which cursors are used, and the animation's speed.  See the User Manual for        }
  62. {                        details.                                                                                        }
  63. {                                                                                                                    }
  64. {    FREF        128        Finder Reference:  This resource is automatically created when a BNDL resource is created.    }
  65. {                        One FREF exists for each icon that the Finder references.  This demo is an application        }
  66. {                        (file type is 'APPL'), so one FREF is needed for that.  If this demo had the ability to create    }
  67. {                        three different kinds of documents, then one FREF would be required for each kind type of    }
  68. {                        document.                                                                                    }
  69. {                                                                                                                    }
  70. {    icl4            - -        Large (32x32 pixel) 4-bit Icons:  These icons are typically used only by the Finder to depict    }
  71. {                        an application and its related files.  However, your application can also draw these icons        }
  72. {                        with Tools Plus.  4-bit icons can have a maximum of 16 colors.                                }
  73. {                0,1,2    These color icons will be used on color monitors as a substitute for the system's Stop, Note    }
  74. {                        and Caution icons.  They give color applications a better look.                                }
  75. {                128        Application's Icon (displayed by the Finder.  The BNDL resource refers to this icon)            }
  76. {                150        Printer icon used to demonstrate drawing icon families                                        }
  77. {                151        Modem icon used to demonstrate drawing icon families                                        }
  78. {            400,401    Left Arrow button used in Picture Buttons demo (part of an icl8 / icl4 / ICN# family).  One icon}
  79. {                        is used for the button's standard position, and another for the selected (pushed in) position.    }
  80. {            402,403    Right Arrow button used in Picture Buttons demo (similar to above)                            }
  81. {            420-425    Plus/Minus button used in Picture Buttons demo.  These 4 icons are used in a particularly    }
  82. {                        attractive button.  The top half (+) darkens when you select it, and so does the bottom (-).    }
  83. {                        Two icons (standard and selected position) are used for the top half, and two for the bottom.    }
  84. {                        These icons are part of an icl8 / icl4 / ICN# family.                                            }
  85. {            450-456    Four icons are used to draw a dual-stage button (Power-On / Power-Off) in the Picture        }
  86. {                        Buttons demo; a pair for each stage, one for the standard state and one for the selected        }
  87. {                        (pushed in) state.  An additional pair of icons ause used to portray the buttons as disabled;    }
  88. {                        one for Power-On and one for Power-Off.  These icons are part of an icl8 / icl4 / ICN# family.    }
  89. {                                                                                                                    }
  90. {    icl8            - -        Large (32x32 pixel) 8-bit Icons:  These icons are typically used only by the Finder to depict    }
  91. {                        an application and its related files.  However, your application can also draw these icons        }
  92. {                        with Tools Plus.  8-bit icons can have a maximum of 256 colors.                                }
  93. {                1,2        These color icons will be used on color monitors as a substitute for the system's Note and    }
  94. {                        Caution icons.  They give color applications a better look.  Notice that there isn't a Stop icon    }
  95. {                        (ID=0).  The equivalent icl4 will be used instead.                                                }
  96. {                128        Application's Icon (displayed by the Finder.  The BNDL resource refers to this icon)            }
  97. {                150        Printer icon used to demonstrate drawing icon families                                        }
  98. {                151        Modem icon used to demonstrate drawing icon families                                        }
  99. {            400,401    Left Arrow button used in Picture Buttons demo (part of an icl8 / icl4 / ICN# family).  One icon}
  100. {                        is used for the button's standard position, and another for the selected (pushed in) position.    }
  101. {            402,403    Right Arrow button used in Picture Buttons demo (similar to above)                            }
  102. {            420-425    Plus/Minus button used in Picture Buttons demo.  These 4 icons are used in a particularly    }
  103. {                        attractive button.  The top half (+) darkens when you select it, and so does the bottom (-).    }
  104. {                        Two icons (standard and selected position) are used for the top half, and two for the bottom.    }
  105. {                        These icons are part of an icl8 / icl4 / ICN# family.                                            }
  106. {            450-456    Four icons are used to draw a dual-stage button (Power-On / Power-Off) in the Picture        }
  107. {                        Buttons demo; a pair for each stage, one for the standard state and one for the selected        }
  108. {                        (pushed in) state.  An additional pair of icons ause used to portray the buttons as disabled;    }
  109. {                        one for Power-On and one for Power-Off.  These icons are part of an icl8 / icl4 / ICN# family.    }
  110. {                                                                                                                    }
  111. {    ICN#        - -        Large (32x32 pixel) 1-bit Icons with Mask:  These icons are typically used only by the Finder    }
  112. {                        to depict an application and its related files.  However, your application can also draw these    }
  113. {                        icons with Tools Plus.  1-bit icons are black and white (no shades of gray).                    }
  114. {                128        Application's Icon (displayed by the Finder.  The BNDL resource refers to this icon)            }
  115. {                150        Printer icon used to demonstrate drawing icon families                                        }
  116. {                151        Modem icon used to demonstrate drawing icon families                                        }
  117. {            400,401    Left Arrow button used in Picture Buttons demo (part of an icl8 / icl4 / ICN# family).  One icon}
  118. {                        is used for the button's standard position, and another for the selected (pushed in) position.    }
  119. {            402,403    Right Arrow button used in Picture Buttons demo (similar to above)                            }
  120. {            420-425    Plus/Minus button used in Picture Buttons demo.  These 4 icons are used in a particularly    }
  121. {                        attractive button.  The top half (+) darkens when you select it, and so does the bottom (-).    }
  122. {                        Two icons (standard and selected position) are used for the top half, and two for the bottom.    }
  123. {                        These icons are part of an icl8 / icl4 / ICN# family.                                            }
  124. {            450-456    Four icons are used to draw a dual-stage button (Power-On / Power-Off) in the Picture        }
  125. {                        Buttons demo; a pair for each stage, one for the standard state and one for the selected        }
  126. {                        (pushed in) state.  An additional pair of icons ause used to portray the buttons as disabled;    }
  127. {                        one for Power-On and one for Power-Off.  These icons are part of an icl8 / icl4 / ICN# family.    }
  128. {                                                                                                                    }
  129. {    ICON        - -        Large (32x32 pixel) 1-bit Icons:  These are standard black & white icons.                    }
  130. {                0,1,2    These icons will be used as a substitute for the system's Stop, Note and Caution icons.        }
  131. {                        In this case, they are exactly the same as System 7's system icons, but they are included    }
  132. {                        in case this application runs on System 5 (where the system icons are different).  There are    }
  133. {                        color counterparts for these icons (icl4 and icl8).                                            }
  134. {            304,305    These printer and modem icons appear in 'picture Pop-Up Menus' (picture in a Pop-Up Menu    }
  135. {                        without any text) on Macs without Color QuickDraw.  There are 'cicn' equivalents for these    }
  136. {                        items for Macs with Color QuickDraw.                                                        }
  137. {                                                                                                                    }
  138. {    ics4        - -        Small (16x16 pixel) 4-bit Icons:  These icons are typically used only by the Finder to depict    }
  139. {                        an application and its related files.  4-bit icons can have a maximum of 16 colors.            }
  140. {                128        Application's Icon (displayed by the Finder.  The BNDL resource refers to this icon)            }
  141. {                                                                                                                    }
  142. {    ics8        - -        Small (16x16 pixel) 8-bit Icons:  These icons are typically used only by the Finder to depict    }
  143. {                        an application and its related files.  8-bit icons can have a maximum of 256 colors.            }
  144. {                128        Application's Icon (displayed by the Finder.  The BNDL resource refers to this icon)            }
  145. {                                                                                                                    }
  146. {    ics#        - -        Small (16x16 pixel) 1-bit Icons with mask:  These icons are typically used only by the Finder    }
  147. {                        to depict an application and its related files.  1-bit icons are black & white.                    }
  148. {                128        Application's Icon (displayed by the Finder.  The BNDL resource refers to this icon)            }
  149. {                                                                                                                    }
  150. {    PICT        - -        Pictures of any dimension, number of colors (including gray scale and black & white)        }
  151. {                128        Black & white (1-bit) picture.  It's the black & white equivalent of resource 129.                }
  152. {                129        Color (8-bit) picture.  It's the color equivalent of resource 128.                                }
  153. {            150-173    Complete picture suite needed for a 2-stage button. Each stage (value) can be either        }
  154. {                        or not, and includes different PICTs for screen depths of 8-bits, 4-bits, and B&W. They also    }
  155. {                        include a mask, though this is not necessary when drawing on a white background.            }
  156. {                                                                                                                    }
  157. {    SICN        - -        Small (16x16 pixel) 1-bit Icons:  These icons are 'indexed', meaning that you can have        }
  158. {                        multiple icon images in a single 'SICN' resource.                                                }
  159. {            300-303    These color icons (hard disk, floppy, and folder) show up in the Pop-Up Menus demo beside    }
  160. {                        menu item names. They are supplied because Macs without Color QuickDraw need SICNs    }
  161. {                        (they can't use color 'cicn' icons).                                                            }
  162. {            408-414    These are all used in the Picture Buttons demo to create 3D icons.  Tools Plus converts an    }
  163. {                        SICN icon into a color 3D button.                                                            }
  164. {                458        These are all used in the Picture Buttons demo to create 3D icons.  Tools Plus converts an    }
  165. {                        SICN icon into a color 3D button.  Because this SICN resource has several images, each    }
  166. {                        image becomes an available 'state' (or usable value).  In this example, the user can step    }
  167. {                        through the stages by clicking on the button.                                                }
  168. {            500-519    These are all used in the Floating Palettes demo to create 3D icons.  Tools Plus converts an    }
  169. {                        SICN icon into a color 3D button.  You can create professional looking palettes with different    }
  170. {                        styles of buttons using Tools Plus.                                                            }
  171. {                                                                                                                    }
  172. {    SIZE        -1        Multi-tasking info:  The 'SIZE' resource is needed if your application is going to run under    }
  173. {                        MultiFinder (System 5 and 6) or System 7.  It tells the Macintosh how your application        }
  174. {                        should behave in a multi-tasking environment.  See the User Manual for details.                }
  175. {                                                                                                                    }
  176. {    TP 1        128        Owner Resource:  This resource is automatically created when a BNDL resource is created.    }
  177. {                        This demo's signature is 'TP 1', and as you may recall, each application must have a unique    }
  178. {                        signature code (see the User Manual for details).  That signature code is used to create an    }
  179. {                        'owner resource' whose resource type is the same as the application's signature code.        }
  180. {                                                                                                                    }
  181. {    vers        - -        Application Version:  These resources' information is displayed in the Finder's Get Info box.    }
  182. {                1        This information is displayed at the bottom of the Get Info box.  It includes an application    }
  183. {                        version number and the copyright info.                                                        }
  184. {                2        This information is displayed at the top of the Get Info box.  It is a comment that is displayed    }
  185. {                        beneath the application's name (ie:  'Tools Plus demo').                                        }
  186. {                                                                                                                    }
  187. {    WDEF        - -        Window Definition:  WDEFs define how a window looks.  If you want to open a window that is    }
  188. {                        not one of the six standard Macintosh window types, you have to create a window definition.    }
  189. {                2000    Pallet Window:  These windows have a narrow title bar, and are typically used as 'floating    }
  190. {                        windows' (they are always active, and they float above your other windows).  This demo has    }
  191. {                        several floating pallets.                                                                        }
  192.  
  193.  
  194. {    T h e   D e m o s :                                                                                                }
  195. {    This demo application can be used as a framework for a new application, although you will probably want to        }
  196. {    improve upon it to cater to your own programming style and needs.  The demo can be broken down into several    }
  197. {    sections:                                                                                                        }
  198. {                                                                                                                    }
  199. {            main        The main program (at the bottom of this source code) demonstrates a typical application's    }
  200. {                        startup and response to events.                                                            }
  201. {                                                                                                                    }
  202. {    PrepareTheDemo    This routine creates the demos menus and opens a couple demo windows.                    }
  203. {                                                                                                                    }
  204. {        Window 1        This window demonstrates how Tools Plus works with…                                        }
  205. {                            • List Boxes                                                                            }
  206. {                            • Buttons (radio buttons, check boxes and push buttons)                                }
  207. {                            • Cursor Zones                                                                            }
  208. {                                                                                                                    }
  209. {        Window 2        This window demonstrates how Tools Plus works with…                                        }
  210. {                            • Editing Fields (typing, Cut, Copy, Paste, Clear, and Undo.  Tabbing to next / prev field)    }
  211. {                            • Scroll Bars                                                                            }
  212. {                            • 'Size box' and the 'zoom box' (changing a window's size)                                }
  213. {                                                                                                                    }
  214. {        Window 3        This window demonstrates how Tools Plus works with…                                        }
  215. {                            • drawing icon families                                                                    }
  216. {                            • Cursor Zones used to make icons click sensitive                                        }
  217. {                                                                                                                    }
  218. {        Window 4        This window shows off Tools Plus's cursor animation, and how Tools Plus behaves when a    }
  219. {                        watch cursor is displayed.                                                                    }
  220. {                                                                                                                    }
  221. {        Window 5        This window demonstrates how to write code for color drawing that is dependent on the        }
  222. {                        monitor's settings (ie: number of colors, number of shades of gray, or black & white).  It also    }
  223. {                        shows how to write code that is compatible with Macintoshes that have multiple monitors.    }
  224. {                                                                                                                    }
  225. {        Window 6        This demo shows off Tools Plus's Dynamic Alerts.  They are alert boxes that automatically    }
  226. {                        adjust to accommodate the text your application provides them.                                }
  227. {                                                                                                                    }
  228. {        Window 7        This window demonstrates Tools Plus's Pop-Up Menus and some of the features you can    }
  229. {                        incorporate into them.                                                                        }
  230. {                                                                                                                    }
  231. {        Window 8        This window features Tools Plus's Picture Buttons, which transform icons or pictures  into    }
  232. {                        powerful buttons.  Picture Buttons have a list of properties that you can select and combine    }
  233. {                        to create your own custom Picture Buttons.  Picture Button properties control the look and    }
  234. {                        behavior of the button.                                                                        }
  235. {                                                                                                                    }
  236. {        Window 9        Window 9 is this application's Tool Bar.  Tools Plus lets you create a Tool Bar as easily as    }
  237. {                        any other Tools Plus window.  You can put any control you want in the Tool Bar, including    }
  238. {                        picture buttons (the most common thing), pop-up menus, and editing fields.  Demo Window 8    }
  239. {                        describes picture buttons in greater detail.                                                    }
  240. {                                                                                                                    }
  241. {        Window 10        Window 10 is this a floating palette.  Tools Plus lets you create a floating palette as easily    }
  242. {                        as any other Tools Plus window.  You can put any control you want in the Tool Bar, including    }
  243. {                        picture buttons (the most common thing), pop-up menus, and editing fields.  Demo Window 8    }
  244. {                        describes picture buttons in greater detail.                                                    }
  245. {                                                                                                                    }
  246. {        Window 11        Window 11 is this also a floating palette (like demo window 10), except this is a horizontal    }
  247. {                        palette with the title bar along the window's left side.                                            }
  248.  
  249.  
  250. {    S o u n d   M a n a g e r :                                                                                            }
  251. {    This demo uses the Sound Manager just for entertainment's sake.  If this demo runs on a Mac that is running        }
  252. {    less than System 6, simple beeps will be played instead of sounds.                                                }
  253.  
  254.  
  255.  
  256.  
  257.  
  258. program Demo;
  259.     uses
  260.         ToolsPlus, Sound;                                                {Interface to Tools Plus.  Each program or unit    }
  261.                                                                     {    that makes reference to a Tools Plus TYPE,    }
  262.                                                                     {    CONSTant, VARiable or routine needs a        }
  263.                                                                     {    'uses' statement that includes ToolsPlus.    }
  264.                                                                     {    This a demo also uses the Sound Manager    }
  265.                                                                     {    to play a few sounds, just for fun.            }
  266.  
  267.                                                                     {G l o b a l s   t y p e s   a n d   v a r i a b l e s …    }
  268.                                                                     {These CONSTants, TYPEs and VARiables         }
  269.                                                                     {    are accessible throughout this program.    }
  270.     const
  271.     {    All these constants will make the demo's code more readable.  You don't HAVE to use them.  You can use    }
  272.     {    literals, such as 1, 2, 3… if you want to.  It all depends on your writing style and needs.                        }
  273.         DemoWindow1 = 1;                                                {Window numbers for the demo…                }
  274.         DemoWindow2 = 2;                                                {                                                }
  275.         DemoWindow3 = 3;                                                {                                                }
  276.         DemoWindow4 = 4;                                                {                                                }
  277.         DemoWindow5 = 5;                                                {                                                }
  278.         DemoWindow6 = 6;                                                {                                                }
  279.         DemoWindow7 = 7;                                                {                                                }
  280.         DemoWindow8 = 8;                                                {                                                }
  281.         ToolBarWindow = 9;                                                {                                                }
  282.         VerticalPalette = 10;                                            {                                                }
  283.         HorizontalPalette = 11;                                            {                                                }
  284.         OkButton = 1;                                                    {Buttons used on Demo Window 1…                }
  285.         CancelButton = 2;                                                {    When writing a real application, you can        }
  286.         MiniButton1 = 11;                                                {    give these constants meaningful names,    }
  287.         MiniButton2 = 12;                                                {    such as 'OK', 'Cancel', 'Detail', 'Summary'    }
  288.         MiniButton3 = 13;                                                {    etc.                                        }
  289.         MiniButton4 = 14;                                                {                                                }
  290.         MiniButton5 = 15;                                                {                                                }
  291.         CheckBox1 = 21;                                                {                                                }
  292.         CheckBox2 = 22;                                                {                                                }
  293.         CheckBox3 = 23;                                                {                                                }
  294.         RadioButton1 = 31;                                                {                                                }
  295.         RadioButton2 = 32;                                                {                                                }
  296.         RadioButton3 = 33;                                                {                                                }
  297.         MidiHalfMeg = 11;                                                {                                                }
  298.         MidiOneMeg = 12;                                                {                                                }
  299.         MidiTwoMeg = 13;                                                {                                                }
  300.         LeftArrowButton = 1;                                            {Picture Buttons used on Window 8…            }
  301.         RightArrowButton = 2;                                            {    When writing real applications, you can use    }
  302.         LeftAlignButton = 3;                                            {    constants, variables, calculations, or a        }
  303.         CenterAlignButton = 4;                                            {    number in place of these items.                }
  304.         RightAlignButton = 5;                                            {                                                }
  305.         JustifyButton = 6;                                                {                                                }
  306.         CutButton = 7;                                                    {                                                }
  307.         BucketButton = 8;                                                {                                                }
  308.         ClipboardButton = 9;                                            {                                                }
  309.         PlusButton = 10;                                                {                                                }
  310.         MinusButton = 11;                                                {                                                }
  311.         PrinterButton = 12;                                                {                                                }
  312.         ModemButton = 13;                                                {                                                }
  313.         SteppingButton = 14;                                            {                                                }
  314.         ScrollingButton = 15;                                            {                                                }
  315.         GlobeButton = 16;                                                {                                                }
  316.         RewindButton = 17;                                                {                                                }
  317.         StopButton = 18;                                                {                                                }
  318.         FastFwdButton = 19;                                            {                                                }
  319.         PauseButton = 20;                                                {                                                }
  320.         RecordButton = 21;                                                {                                                }
  321.         PlayButton = 22;                                                {                                                }
  322.         PowerButton = 23;                                                {                                                }
  323.         FlipButton = 24;                                                    {                                                }
  324.         DoneButton = 25;                                                {                                                }
  325.         VPaletteMinButton = 1;                                            {First and last picture button used on the        }
  326.         VPaletteMaxButton = 20;                                        {    vertical floating palette demo.                }
  327.         HPaletteMinButton = 1;                                            {First and last picture button used on the        }
  328.         HPaletteMaxButton = 22;                                        {    horizontal floating palette demo.            }
  329.         LeftArrowIcon = 400;                                            {Icons and Picture used to make Picture        }
  330.         RightArrowIcon = 404;                                            {    Buttons on Window 8…                        }
  331.         LeftAlignIcon = 408;                                            {                                                }
  332.         CenterAlignIcon = 409;                                            {                                                }
  333.         RightAlignIcon = 410;                                            {                                                }
  334.         JustifyIcon = 411;                                                {                                                }
  335.         CutIcon = 412;                                                    {                                                }
  336.         BucketIcon = 413;                                                {                                                }
  337.         ClipboardIcon = 414;                                            {                                                }
  338.         PlusIcon = 420;                                                    {                                                }
  339.         MinusIcon = 424;                                                {                                                }
  340.         ScrollingIcon = 458;                                            {                                                }
  341.         GlobeIcon = 460;                                                {                                                }
  342.         RewindIcon = 430;                                                {                                                }
  343.         StopTapeIcon = 432;                                            {                                                }
  344.         FastFwdIcon = 434;                                                {                                                }
  345.         PauseIcon = 436;                                                {                                                }
  346.         RecordIcon = 438;                                                {                                                }
  347.         PlayIcon = 440;                                                    {                                                }
  348.         PowerIcon = 450;                                                {                                                }
  349.         FlipSwitchPICT = 150;                                            {                                                }
  350.         DoneIcon = 464;                                                {                                                }
  351.         FirstVPaletteIcon = 500;                                        {First icon number on the vertical and horizontal    }
  352.         FirstHPaletteIcon = 520;                                        {    palettes.  Other icons nums are calculated.    }
  353.         LeftList = 1;                                                    {List Boxes used on Demo Window 1…            }
  354.         RightList = 2;                                                    {                                                }
  355.         RightBar = 1;                                                    {Scroll Bars used on Demo Window 2…            }
  356.         BottomBar = 2;                                                    {                                                }
  357.         ApplMenu = 0;                                                    {Menus and Menu Items…                        }
  358.         AboutItem = 1;                                                    {                                                }
  359.         FileMenu = 1;                                                    {                                                }
  360.         CloseItem = 3;                                                    {                                                }
  361.         QuitItem = 5;                                                    {                                                }
  362.         EditMenu = 2;                                                    {                                                }
  363.         DemosMenu = 3;                                                {                                                }
  364.         ToolBarItem = 10;                                                {Item number for Tool Bar on the Demos menu    }
  365.         PaletteDemoMenu = 16;                                        {Hierarchic menus use numbers 16-200            }
  366.         popMenu1 = 1;                                                    {Pop-Up Menu numbers                            }
  367.         popMenu2 = 2;                                                    {                                                }
  368.         popMenu3 = 3;                                                    {                                                }
  369.         popMenu4 = 4;                                                    {                                                }
  370.         popMenu5 = 5;                                                    {                                                }
  371.         ButtonSpeedMenu = 6;                                            {                                                }
  372.         PrinterIcon = 150;                                                {Printer and Modem icons…                        }
  373.         ModemIcon = 151;                                                {                                                }
  374.         BlackAndWhitePICT = 128;                                        {Color and Black & White pictures…                }
  375.         ColorPICT = 129;                                                {                                                }
  376.         WatersEdgeLogo = 128;                                        {Logo for Water's Edge Software (icon)            }
  377.  
  378.     type
  379.         Str30Handle = ^Str30Ptr;                                        {A 30-character string is defined which can be    }
  380.         Str30Ptr = ^Str30;                                                {    referenced by handle.  Editing fields use    }
  381.         Str30 = string[30];                                                {    handles to automatically maintain their text.    }
  382.  
  383.     var
  384.         Poll: TPPollRecord;                                                {Polling record to retrieve event information        }
  385.         hField1: Str30Handle;                                            {Handle to 1st editing field's 30-char string        }
  386.         hField2, hField3: StringHandle;                                    {Handles to 2nd and 3rd editing fields' 255-char    }
  387.                                                                     {    string.                                        }
  388.         MidiPort: integer;                                                {Serial port selected for MIDI interface (Demo 3)}
  389.         MidiSpeed: integer;                                                {MIDI interface speed (Demo 3)                    }
  390.         ToolBarGray: RGBColor;                                        {Color of toolbar                                }
  391.         ToolBarValue: integer;                                            {Value displayed in a window's tool bar (Demo 8)    }
  392.         ExitTheDemo: boolean;                                            {Should the demo terminate?                    }
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399. { D r a w   T e x t   i n   a   B o x : =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =    }
  400. {    This generic routine performs an often used task of drawing text within a specified rectangle.                    }
  401.     procedure TextInBox (Str: str255;                                {The string that's going to be drawn                }
  402.                                     left, top, right, bottom: integer;                    {Box's co-ordinates                                }
  403.                                     Justification: integer;                                {Left-aligned, centered, or right-aligned            }
  404.                                     withBox: boolean);                                {Draw a box around the text?                    }
  405.         var
  406.             Rectangle: rect;                                                {Box's co-ordinates specified as a rectangle    }
  407.     begin
  408.         SetRect(Rectangle, left, top, right, bottom);                        {Convert the specified co-ordinates into a rect.    }
  409.         TextBox(ptr(ord(@Str) + 1), length(Str), Rectangle, Justification);    {Draw the text in the specified rectangle        }
  410.         if withBox then                                                {If a box is needed around the text…            }
  411.             FrameRect(Rectangle);                                        {    draw the rectangle around the text.            }
  412.     end;                                                                {                                                }
  413.  
  414.  
  415.  
  416.  
  417.  
  418. {  A c t i o n   i n   a   d e m o   W i n d o w : =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =    }
  419. {    The following routines respond to actions made by the user in a demo window.  They are invoked by the main        }
  420. {    event loop whenever the user does any of the following things:                                                    }
  421. {        • Click a button                        (doButton event)                                                        }
  422. {        • Type a key                        (doKeyDown or doAutoKey event, excluding those in editing fields)        }
  423. {        • Click in an inactive editing field    (doClickField event)                                                    }
  424. {        • Use a scroll bar                    (doScrollBar event, excluding those in List Boxes)                        }
  425. {        • Click a line in a List Box            (doListBox)                                                                }
  426. {        • Use a Pop-Up Menu                (doPopUpMenu)                                                        }
  427. {        • Click in the window                (doClick, excluding clicking on other objects listed above)                }
  428.  
  429.  
  430. { C l o s e   A   W i n d o w : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  431. {    This routine is called in response to a "doGoAway" event, the File menu's Close command, and any from some    }
  432. {    demos that end when you click the Cancel or OK button.  Note that a doGoAway event is not generated when a    }
  433. {    desk accessory's "close" box is clicked.                                                                        }
  434. {        A doGoAway event indicates that the user clicked the active window's "close" box.  In a full featured            }
  435. {    application, you may want to validate the active editing field and perform any other verifications before closing    }
  436. {    the window.                                                                                                        }
  437.     procedure CloseTheWindow (Window: integer);                    {Window number being closed                    }
  438.     begin
  439.         WindowClose(Window);                                            {Close the specified window                        }
  440.         if FirstWindowNumber = none then                                {If this application does not have any open        }
  441.                                                                     {    windows…                                    }
  442.             EnableMenu(FileMenu, CloseItem, disabled);                    {Disable the File menu's Close command,        }
  443.     end;                                                                {    because all the windows are closed.        }
  444.  
  445.  
  446. { A c t i o n   i n   D e m o   W i n d o w   1 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  447. {    This routine responds to actions made by the user in demo window 1.  The actions include:                        }
  448. {        • Clicking or double-clicking a line in a List Box                                                                }
  449. {        • Clicking a check box                                                                                        }
  450. {        • Clicking or double clicking a radio button                                                                    }
  451. {        • Clicking a push-button                                                                                        }
  452. {    Notice that if you type Enter or Return, Tools Plus automatically selects the default push button (OK).            }
  453.     procedure ActionInWindow1;
  454.         var
  455.             CheckedBox: boolean;                                        {Was the clicked check box originally selected?    }
  456.             ButtonNum: integer;                                            {Button counter for stepping through as set of    }
  457.                                                                     {    buttons.                                    }
  458.             NumberOfSounds: integer;                                    {Number of sounds in the System file            }
  459.             SoundIndex: integer;                                            {Relative sound number going to be played        }
  460.             hSound: handle;                                                {Handle to a sound resource                    }
  461.             OSerr: integer;                                                {Macintosh operating system error                }
  462.     begin
  463.         case Poll.What of                                                {Determine what the user did (what event)…        }
  464.  
  465.                                                                      { B u t t o n   W a s   S e l e c t e d :    -    -    -    }
  466.                                                                     {This section demonstrates typical interaction    }
  467.                                                                     {    with check boxes, radio button groups and    }
  468.                                                                     {    push buttons.  Look at the radio-button        }
  469.             doButton:                                                    {    group for 'double-clicking' ability.            }
  470.                 case Poll.Button.Num of                                    {Determine which button was selected…        }
  471.  
  472.                     MiniButton1..MiniButton5:                                 { M i n i - B u t t o n s :    -        -        -        }
  473.                         begin                                                    {The mini buttons simply play one of the sounds    }
  474.                                                                     {    available in the System file.                    }
  475.                             NumberOfSounds := CountResources('snd ');            {Determine the number of sounds available        }
  476.                             if (NumberOfSounds = none) or (SystemVersion < 6.0) then    {If there are no sounds available, or if    }
  477.                                 Beep                                                {    the System version does not support the    }
  478.                                                                     {    Sound Manager (older than System 6), just    }
  479.                                                                     {    beep the user.                                }
  480.                             else                                                    {If there are sounds available in the System…    }
  481.                                 begin                                                 {    calculate a 'sound index' number such that    }
  482.                                                                     {    button 1 is the first sound, button 2 is the    }
  483.                                                                     {    second, etc…                                }
  484.                                     SoundIndex := max(1, (Poll.Button.Num - (MiniButton1 - 1)) mod NumberOfSounds);    {            }
  485.                                     hSound := GetIndResource('snd ', SoundIndex);    {Load the sound resource from the System file    }
  486.                                     OSerr := SndPlay(nil, hSound, false);            {Play the sound resource (ignore the error)        }
  487.                                     ReleaseResource(hSound);                        {Release the resource to conserve memory        }
  488.                                 end                                                {                                                }
  489.                         end;
  490.                                                                     { C h e c k   B o x e s :    -        -        -        }
  491.                                                                     {When a check box is clicked, it reverses its    }
  492.                                                                     {    current state (If on, turn off.  If off, turn on).    }
  493.                                                                     {    In this example, the third check box can    }
  494.                                                                      {    only be selected if the second one is        }
  495.                     CheckBox1..CheckBox3:                                    {    selected.                                    }
  496.                         begin                                                    {                                                }
  497.                             CheckedBox := ButtonIsSelected(Poll.Button.Num);    {Determine if check box was originally selected    }
  498.                             CheckedBox := not CheckedBox;                    {Reverse the check box's selection (if on, turn    }
  499.                             SelectButton(Poll.Button.Num, CheckedBox);        {    off.  If off, turn on.)                            }
  500.                             if Poll.Button.Num = CheckBox2 then                {If the second check box was clicked…            }
  501.                                 if CheckedBox then                                {    enable/disable button CheckBox3.  This    }
  502.                                     EnableButton(CheckBox3, enabled)                {    shows how easy it is to set up an "and"        }
  503.                                 else                                                {    condition with two or more check boxes.    }
  504.                                     begin                                            {        Check box 3 is deselected and disabled    }
  505.                                         EnableButton(CheckBox3, disabled);            {    when check box 2 is not selected.  When    }
  506.                                         SelectButton(CheckBox3, notSelected);        {    check box 2 is selected, then check box 3    }
  507.                                     end                                                {    is enabled.                                    }
  508.                         end;                                                    {                                                }
  509.  
  510.                                                                     { R a d i o   B u t t o n s :    -        -        -        }
  511.                                                                     {Radio buttons are logically organized into        }
  512.                                                                     {    groups, and only one radio button can be on    }
  513.                                                                     {    at a time.  Your application can optionally do}
  514.                                                                     {    something else if a radio button is double-    }
  515.                                                                     {    clicked.  In this case, it is the equivalent of    }
  516.                     RadioButton1..RadioButton3:                             {    selecting the radio button and clicking OK.    }
  517.                         begin                                                    {                                                }
  518.                             for ButtonNum := RadioButton1 to RadioButton3 do    {Cycle through each button in the group…        }
  519.                                 SelectButton(ButtonNum, ButtonNum = Poll.Button.Num);    {Select the clicked one, deselect the    }
  520.                                                                             {    others.                                }
  521.                             if Poll.Button.DoubleClick then                        {If a radio button was double-clicked…            }
  522.                                 begin                                                {    it means 'select this button and OK'.  Flash    }
  523.                                     FlashButton(OkButton);                            {    the OK button to indicate it's being selected.}
  524.                                     CloseTheWindow(DemoWindow1);                {End this demo by closing its window            }
  525.                                 end                                                {                                                }
  526.                         end;                                                    {                                                }
  527.  
  528.                                                                     { P u s h   B u t t o n s :    -        -        -        }
  529.                     CancelButton, OkButton:                                 {If the user clicked Cancel or OK…                }
  530.                         CloseTheWindow(DemoWindow1);                        {    end this demo by closing its window.        }
  531.                 end;                                                        {                                                }
  532.  
  533.                                                                     { L i s t   B o x e s :        -        -        -        }
  534.                                                                     {Your application may want to respond to a user    }
  535.                                                                     {    selecting a line in a List Box.  This demo just}
  536.                                                                     {    responds to double-clicks by being the        }
  537.                                                                     {    equivalent of selecting the line and clicking    }
  538.                                                                     {    OK.                                        }
  539.             doListBox:                                                     {                                                }
  540.                 if Poll.ListBox.DoubleClick then                            {If a list box was double-clicked…                }
  541.                     begin                                                    {    it means 'select this line and OK'.  Flash the    }
  542.                         FlashButton(OkButton);                                {    OK button to indicate it's being selected.    }
  543.                         CloseTheWindow(DemoWindow1);                        {End this demo by closing its window            }
  544.                     end;                                                        {                                                }
  545.  
  546.             otherwise                                                    {All other events are ignored                    }
  547.         end                                                            {                                                }
  548.     end;
  549.  
  550.  
  551. { A c t i o n   i n   D e m o   W i n d o w   2 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  552. {    This routine responds to actions made by the user in demo window 2.  The actions include:                        }
  553. {        • Clicking or double-clicking in an inactive editing field                                                        }
  554. {        • Using Scroll Bars                                                                                            }
  555. {        • Tabbing to the next (or previous) field                                                                        }
  556.     procedure ActionInWindow2;
  557.         var
  558.             Field: integer;                                                    {Field number                                    }
  559.     begin
  560.         case Poll.What of                                                {Determine what the user did (what event)…        }
  561.  
  562.                                                                      { I n a c t i v e   F i e l d   W a s   C l i c k e d :    -    }
  563.                                                                     {In a full-featured application, you would likely    }
  564.                                                                     {    validate a field for errors before proceeding    }
  565.                                                                     {    to the one clicked by the user.  In this demo,}
  566.             doClickField:                                                    {    no validation is done.                        }
  567.                 begin                                                        {                                                }
  568.                     SaveFieldString;                                            {Save the field's edited text as the field's string    }
  569.                     ClickInField;                                                {Process the event to activate the clicked field    }
  570.                 end;                                                        {    and to set the insertion point or selection    }
  571.                                                                     {    range as per the click.                        }
  572.  
  573.                                                                     { S c r o l l   B a r   W a s   U s e d :    -    -    -    }
  574.                                                                     {Tools Plus tells your application when a scroll    }
  575.                                                                     {    bar is used by either clicking in the up arrow,}
  576.                                                                     {    down arrow, "page up" region, "page down"    }
  577.                                                                     {    region, or by moving the thumb.  Your        }
  578.                                                                     {    application would then respond by doing    }
  579.                                                                     {    something.  This demo doesn't actually        }
  580.                                                                     {    scroll anything.                                }
  581.                                                                     {        Note: When setting a Scroll Bar's value,    }
  582.                                                                     {    the minimum / maximum limit are            }
  583.                                                                     {    automatically adjusted (if necessary).  Here    }
  584.                                                                     {    we use the limits to prevent the current        }
  585.                                                                     {    value from being exceeded.                    }
  586.             doScrollBar:                                                     {                                                }
  587.                 case Poll.ScrollBar.Part of                                {Appropriate action is taken according to the    }
  588.                     inUpButton:                                                 {    part of the scroll bar that was clicked…    }
  589.                         SetScrollBarVal(Poll.ScrollBar.Num, max(GetScrollBarMin(Poll.ScrollBar.Num), GetScrollBarVal(Poll.ScrollBar.Num) - 1));
  590.                     inPageUp: 
  591.                         SetScrollBarVal(Poll.ScrollBar.Num, max(GetScrollBarMin(Poll.ScrollBar.Num), GetScrollBarVal(Poll.ScrollBar.Num) - 10));
  592.                     inDownButton: 
  593.                         SetScrollBarVal(Poll.ScrollBar.Num, min(GetScrollBarMax(Poll.ScrollBar.Num), GetScrollBarVal(Poll.ScrollBar.Num) + 1));
  594.                     inPageDown: 
  595.                         SetScrollBarVal(Poll.ScrollBar.Num, min(GetScrollBarMax(Poll.ScrollBar.Num), GetScrollBarVal(Poll.ScrollBar.Num) + 10));
  596.                     inThumb:                                                    {Ignore thumb movement                        }
  597.                 end;
  598.                                                                     { U s e r   T y p e d   a   K e y :    -    -    -    -    -    }
  599.                                                                     {If the active window has an active editing field,    }
  600.                                                                     {    it automatically processes most key        }
  601.                                                                     {    strokes.  In this example, we only check for    }
  602.                                                                     {    the Tab key, which is used to tab to the next}
  603.                                                                     {    or previous field (Shift-Tab)…                }
  604.             doKeyDown, doAutoKey:                                         {                                                }
  605.                 if (Poll.Key.Chr = TabKey) and not (Poll.Modifiers.CmdKey or Poll.Modifiers.OptionKey or Poll.Modifiers.ControlKey) then
  606.                     begin                                                    {If the Tab key was typed without the Command,}
  607.                                                                     {    Option or Control modifier keys, tab to the    }
  608.                                                                     {    next / previous field.                        }
  609.                                                                     {        In a full-featured application, you would    }
  610.                                                                     {    likely validate a field for errors before        }
  611.                                                                     {    proceeding to the field clicked by the user.    }
  612.                                                                     {    In this demo, no validation is done.            }
  613.                         SaveFieldString;                                        {Save the field's edited text as the field's string    }
  614.                         Field := ActiveFieldNumber;                                {Determine the active field number                }
  615.                         if not Poll.Modifiers.ShiftKey then                    {TAB: to next field…                            }
  616.                             Field := Field + 1 - 3 * ord(Field = 3)                    {    Add 1.  If field=3, start at 1 again.            }
  617.                         else                                                    {SHIFT-TAB: to previous field…                    }
  618.                             Field := Field - 1 + 3 * ord(Field = 1);                    {    Subtract 1.  If field=1, start at 3.            }
  619.                         ActivateField(Field, teSelectAll);                        {Select all the text in the newly activated field    }
  620.                     end;                                                        {                                                }
  621.  
  622.             otherwise                                                    {All other events are ignored                    }
  623.         end                                                            {                                                }
  624.     end;
  625.  
  626.  
  627. { A c t i o n   i n   D e m o   W i n d o w   3 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  628. {    This routine responds to actions made by the user in demo window 3.  The actions include:                        }
  629. {        • Clicking on an icon (Cursor Zone over the icon)                                                                }
  630. {        • Clicking a radio button                                                                                        }
  631.     procedure ActionInWindow3;
  632.         var
  633.             ClickedZone: integer;                                            {Cursor zone clicked by user                    }
  634.             Button: integer;                                                {Button number counter                            }
  635.     begin
  636.         case Poll.What of                                                {Determine what the user did (what event)…        }
  637.  
  638.                                                                     { U s e r   C l i c k e d   I n   T h e   W i n d o w :    -    }
  639.                                                                     {The only click we care about in this window is if    }
  640.             doClick:                                                        {    it occurs in either of the two icons…            }
  641.                 begin                                                        {                                                }
  642.                     ResetMouseClicks;                                        {Only 1st mouse-down is needed.  Ignore rest.    }
  643.                     ClickedZone := FindCursorZone(Poll.Mouse.Down[1].Where);    {Determine which cursor zone was clicked    }
  644.                                                                         {    by the user.                            }
  645.                     if (ClickedZone <> 0) and (ClickedZone <> MidiPort) then{If a Cursor Zone was clicked, and the clicked    }
  646.                         begin                                                    {    zone is different from the currently selected    }
  647.                                                                     {    MIDI port (ie: it was changed)…                }
  648.                             if ClickedZone = PrinterIcon then                    {Depending on which icon was clicked, set the    }
  649.                                 MidiPort := PrinterIcon                                {    MidiPort variable to the selected icon.        }
  650.                             else                                                    {                                                }
  651.                                 MidiPort := ModemIcon;                                {                                                }
  652.                             DrawIcon(PrinterIcon, 20, 32, enabled, MidiPort = PrinterIcon);    {Redraw the printer and modem        }
  653.                             DrawIcon(ModemIcon, 65, 32, enabled, MidiPort = ModemIcon);    {    icons as currently selected.    }
  654.                         end                                                    {                                                }
  655.                 end;                                                        {                                                }
  656.  
  657.             doButton:                                                     { U s e r   C l i c k e d   A   B u t t o n :    -    -    -    }
  658.                 begin                                                        {                                                }
  659.                     for Button := MidiHalfMeg to MidiTwoMeg do                {Cycle through all 3 speed buttons and set only    }
  660.                         SelectButton(Button, Button = Poll.Button.Num);        {    the selected one.  Turn the others off.        }
  661.                     MidiSpeed := Poll.Button.Num;                            {Keep track of the selected button                }
  662.                 end;                                                        {                                                }
  663.  
  664.             otherwise                                                    {Ignore all other events                            }
  665.         end                                                            {                                                }
  666.     end;
  667.  
  668.  
  669. { A c t i o n   i n   D e m o   W i n d o w   4 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  670. {    This routine responds to actions made by the user in demo window 4.  This routine is here for cosmetic reasons    }
  671. {    only, and you can get rid of it if you want.                                                                        }
  672.     procedure ActionInWindow4;
  673.     begin
  674.     end;
  675.  
  676.  
  677. { A c t i o n   i n   D e m o   W i n d o w   5 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  678. {    This routine responds to actions made by the user in demo window 5.  The only thing the user can do is click the    }
  679. {    default OK button, which closes the window.                                                                    }
  680.     procedure ActionInWindow5;
  681.     begin
  682.         if Poll.What = doButton then                                    {If the user clicked a button…                    }
  683.             CloseTheWindow(DemoWindow5);                            {    end this demo by closing its window.        }
  684.     end;                                                                {                                                }
  685.  
  686.  
  687. { A c t i o n   i n   D e m o   W i n d o w   6 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  688. {    This routine responds to actions made by the user in demo window 6.  Dynamic Alerts take care of responding to    }
  689. {    any action from the user, so you don't have to write any code for it.  This routine is here for cosmetic reasons    }
  690. {    only, and you can get rid of it if you want.                                                                        }
  691.     procedure ActionInWindow6;
  692.     begin
  693.     end;
  694.  
  695.  
  696. { A c t i o n   i n   D e m o   W i n d o w   7 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  697. {    This routine responds to actions made by the user in demo window 7.  The only thing you can do is select an item    }
  698. {    in a pop-up menu.                                                                                                }
  699.     procedure ActionInWindow7;
  700.         const
  701.             SilentContinueAlert = -11500;                                    {Button definition for a "Continue" dynamic alert    }
  702.                                                                     {    that doesn't beep the user.                    }
  703.         var
  704.             AltButton: integer;                                            {Button number clicked in an alert box            }
  705.     begin
  706.         if Poll.What = doPopUpMenu then                                {The only thing you can do: use a pop-up menu    }
  707.             case Poll.Menu.Num of                                        {Determine which Pop-Up Menu was selected…    }
  708.  
  709.                 popMenu1, popMenu5:                                         {Pop-Up Menus 1 and 5 use a bullet (•) to mark a    }
  710.                     PopUpMark(Poll.Menu.Num, Poll.Menu.Item, DotChar);    {    selected item.  Mark the new selection now.    }
  711.  
  712.                 popMenu2, popMenu3:                                         {Pop-Up Menus 2 and 3 use a check (√) to mark    }
  713.                     CheckPopUp(Poll.Menu.Num, Poll.Menu.Item, on);        {    selected items.  Mark the new selection.    }
  714.  
  715.                 popMenu4:                                                     {This menu is a "fixed title" pop-down menu.        }
  716.                                                                     {    Such menus are usually used to "do some-    }
  717.                                                                     {    thing now".  This demo just displays an alert.}
  718.                     AltButton := AlertBox(WatersEdgeLogo, 'Your application would do something now, such as displaying a dialog that lets the user specify formatting characteristics.', SilentContinueAlert);
  719.             end                                                            {                                                }
  720.     end;
  721.  
  722.  
  723. { A c t i o n   i n   D e m o   W i n d o w   8 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  724. {    There are three routines for responding to events in this window.  The first two are button value drawing routines    }
  725. {    that display a button's value.  They are called when the button is clicked, or when the window is refreshed.        }
  726.  
  727. {    This routine displays a value in the tool bar.  It is called whenever the 'plus' or 'minus' buttons are used, and        }
  728. {    when the screen is refreshed.                                                                                    }
  729.     procedure ActionInWindow8_DrawToolBarValue;
  730.         var
  731.             theNumber: str255;                                            {Button's value represented as a string            }
  732.     begin
  733.         NumToString(ToolBarValue, theNumber);                        {Convert tool bar number to a string                }
  734.         TextFont(systemFont);                                            {Set the window's font to Chicago 12pt.            }
  735.         TextSize(12);                                                    {                                                }
  736.         PenColorNormal;                                                {PEN: 1 x 1 size, black color, patCopy mode    }
  737.         TextInBox(theNumber, 401, 6, 439, 22, teJustCenter, true);        {Draw the value in the window's tool bar with a    }
  738.     end;                                                                {    frame around it.                                }
  739.  
  740. {    This routine displays the value of the 'Globe' button.  It is called whenever the 'Globe' button is used, and when    }
  741. {    the screen is refreshed.                                                                                        }
  742.     procedure ActionInWindow8_DrawGlobeValue;
  743.         var
  744.             ButtonValue: integer;                                            {Globe button's value                            }
  745.             theNumber: str255;                                            {Button's value represented as a string            }
  746.     begin
  747.         ButtonValue := GetPictButtonVal(GlobeButton);                {Get the 'globe' button's value                    }
  748.         NumToString(ButtonValue, theNumber);                        {Convert to a string                                }
  749.         theNumber := concat(theNumber, '°');                            {Add the degree symbol to the end of the string    }
  750.         TextFont(systemFont);                                            {Set the window's font to Chicago 12pt.            }
  751.         TextSize(12);                                                    {                                                }
  752.         TextInBox(theNumber, 408, 201, 448, 217, teJustRight, false);    {Draw the button's value below the button        }
  753.     end;                                                                {                                                }
  754.  
  755. {    This routine responds to actions made by the user in demo window 8.  This window contains mostly Picture        }
  756. {    Buttons, so the response is limited to the user clicking on these buttons.  Notice that the buttons are organized    }
  757. {    into different types: simple binary clusters, multi-stage buttons, radio button clusters, etc.                        }
  758.     procedure ActionInWindow8;
  759.         var
  760.             theButton: integer;                                            {Button counter                                    }
  761.     begin
  762.         case Poll.What of                                                {Determine what the user did (what event)…        }
  763.  
  764.  
  765.             doPopUpMenu:                                                 { P o p - U p   M e n u   W a s   S e l e c t e d :        }
  766.                 begin                                                        {                                                }
  767.                     PopUpMark(Poll.Menu.Num, Poll.Menu.Item, '√');            {Check selected item (others are unchecked)    }
  768.                     if Poll.Menu.Num = ButtonSpeedMenu then                {If this menu regulate's the 'globe' button speed,}
  769.                         SetPictButtonAccel(GlobeButton, Poll.Menu.Item - 1);    {    set the button's acceleration curve.            }
  770.                 end;                                                        {                                                }
  771.  
  772.  
  773.             doPictButton:                                                { P i c t u r e   B u t t o n   W a s   S e l e c t e d :    }
  774.                 case Poll.Button.Num of                                    {This section demonstrates typical interaction    }
  775.                                                                     {    with check boxes, radio button groups and    }
  776.                                                                     {    push buttons.                                }
  777.                     LeftAlignButton, CenterAlignButton, RightAlignButton, JustifyButton: {Cycle through the group and turn    }
  778.                         for theButton := LeftAlignButton to JustifyButton do                {    off the ones that weren't clicked}
  779.                             SelectPictButton(theButton, theButton = Poll.Button.Num);        {    (deselect them).                }
  780.  
  781.                                                                     {This is the simplest case for picture buttons,    }
  782.                     PrinterButton, ModemButton:                                {    clickable icons…                            }
  783.                         for theButton := PrinterButton to ModemButton do        {Only 1 icon can be on, so turn the other off.    }
  784.                             SelectPictButton(theButton, theButton = Poll.Button.Num);    {                                        }
  785.  
  786.  
  787.                                                                     {Tape Deck buttons: Because each button        }
  788.                                                                     {    locks down (if required) by itself, we just    }
  789.                                                                     {    have to deselect any other button that may    }
  790.                                                                     {    be down…                                    }
  791.                     RewindButton, StopButton, FastFwdButton, PauseButton, RecordButton, PlayButton:     {                }
  792.                         for theButton := RewindButton to PlayButton do        {Cycle through all the buttons…                    }
  793.                             if theButton <> Poll.Button.Num then                {If this button was not clicked…                    }
  794.                                 SelectPictButton(theButton, notSelected);            {    deselect the button.                        }
  795.  
  796.  
  797.                     GlobeButton, -GlobeButton:                                {If the globe button was selected and/or held…    }
  798.                         ActionInWindow8_DrawGlobeValue;                    {    show the new value.  The negative case is    }
  799.                                                                     {    for the decrementing side of the button.        }
  800.  
  801.  
  802.                     PlusButton:                                                 {'Plus' button in window's tool bar:                }
  803.                         if ToolBarValue < 3200 then                            {If the current value is less that 3200 (the        }
  804.                             begin                                                {    upper limit)…                                }
  805.                                 ToolBarValue := ToolBarValue * 2;                    {Double the 'zoom factor'                        }
  806.                                 ActionInWindow8_DrawToolBarValue;                {Redisplay the tool bar's number                }
  807.                             end;                                                    {                                                }
  808.  
  809.                     MinusButton:                                             {'Minus' button in window's tool bar:                }
  810.                         if ToolBarValue > 25 then                                {If the current value is greater than 25 (the lower}
  811.                             begin                                                {    limit)…                                        }
  812.                                 ToolBarValue := ToolBarValue div 2;                {Half the 'zoom factor'                            }
  813.                                 ActionInWindow8_DrawToolBarValue;                {Redisplay the tool bar's number                }
  814.                             end;                                                    {                                                }
  815.  
  816.  
  817.                     DoneButton:                                                 {If the user clicked the 'Done' button…            }
  818.                         CloseTheWindow(DemoWindow8);                        {    end this demo by closing its window.        }
  819.  
  820.                     otherwise                                                {Ignore all other buttons                        }
  821.                 end;                                                        {                                                }
  822.  
  823.             otherwise                                                    {Ignore all other kinds of events                    }
  824.         end                                                            {                                                }
  825.     end;                                                                {                                                }
  826.  
  827.  
  828. { A c t i o n   i n   D e m o   W i n d o w   9 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  829. {    This routine responds to actions made by the user in demo window 9 (the Tool Bar).  You can select an item in    }
  830. {    Pop-Up Menu or click picture buttons, but the picture buttons don't do anything in this demo.                    }
  831.     procedure ActionInWindow9;
  832.         var
  833.             theButton: integer;                                            {Button counter                                    }
  834.     begin
  835.         if Poll.What = doPopUpMenu then                                {If the pop-up menu was used…                    }
  836.             PopUpMark(Poll.Menu.Num, Poll.Menu.Item, '√')                {    check selected item (others are unchecked)}
  837.  
  838.                                                                     {If one of the 4 'single selection' buttons was    }
  839.                                                                     {    selected…                                    }
  840.         else if (Poll.What = doPictButton) and (Poll.Button.Num >= LeftAlignButton) and (Poll.Button.Num <= JustifyButton) then
  841.             for theButton := LeftAlignButton to JustifyButton do            {Cycle through the group and turn off the ones    }
  842.                 SelectPictButton(theButton, theButton = Poll.Button.Num);    {    that weren't clicked (deselect them).        }
  843.     end;                                                                {                                                }
  844.  
  845.  
  846. { A c t i o n   i n   D e m o   W i n d o w   10 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  847. {    This routine responds to actions made by the user in demo window 10 (a vertical palette).  All the user can do is    }
  848. {    click a picture button, but the picture buttons don't do anything in this demo.                                    }
  849.     procedure ActionInWindow10;
  850.         var
  851.             theButton: integer;                                            {Button counter                                    }
  852.     begin
  853.         if Poll.What = doPictButton then                                {If the user clicked on a picture button…        }
  854.             for theButton := VPaletteMinButton to VPaletteMaxButton do{Cycle through the group and turn off the ones    }
  855.                 SelectPictButton(theButton, theButton = Poll.Button.Num);    {    that weren't clicked (deselect them).        }
  856.     end;                                                                {                                                }
  857.  
  858.  
  859. { A c t i o n   i n   D e m o   W i n d o w   11 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  860. {    This routine responds to actions made by the user in demo window 11 (a horizontal palette).  All the user can do    }
  861. {    is click a picture button, but the picture buttons don't do anything in this demo.                                    }
  862.     procedure ActionInWindow11;
  863.         var
  864.             theButton: integer;                                            {Button counter                                    }
  865.     begin
  866.         if Poll.What = doPictButton then                                {If the user clicked on a picture button…        }
  867.             for theButton := HPaletteMinButton to HPaletteMaxButton do{Cycle through the group and turn off the ones    }
  868.                 SelectPictButton(theButton, theButton = Poll.Button.Num);    {    that weren't clicked (deselect them).        }
  869.     end;                                                                {                                                }
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880. {  D r a w   D e m o   W i n d o w s '   C o n t e n t s : =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =    }
  881. {    The following routines are used to draw a demo windows' contents.  They are invoked when a demo window is    }
  882. {    first opened, and when a demo window needs to be refreshed.  The contents includes text and lines.  It excludes    }
  883. {    Tools Plus objects such as Buttons, Scroll Bars, List Boxes, Editing Fields, etc.  Those objects are refreshed    }
  884. {    automatically.                                                                                                    }
  885.  
  886.  
  887. { D r a w   a   G r o u p   B o x   w i t h   a   T i t l e : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  888. {    This generic routine performs an often used task of drawing a "Group Box" such as the kind that is seen around    }
  889. {    a radio-button group.  It also draws the group's title at the top of the box.  The box is drawn using the pen's        }
  890. {    current size, pattern and transfer mode.  The group's title is drawn using the window's current font, size, and        }
  891. {    style.                                                                                                            }
  892.     procedure GroupBox (Str: str255;                                {Group's name                                    }
  893.                                     left, top, right, bottom: integer);                    {Co-ordinates of the group's enclosing box        }
  894.         var
  895.             Rectangle: rect;                                                {Box's co-ordinates specified as a rectangle    }
  896.             TextRect: rect;                                                {Enclosing ractangle where box will appear        }
  897.             Width: integer;                                                {Text's width (for centering it)                    }
  898.     begin
  899.         SetRect(Rectangle, left, top, right, bottom);                        {Convert the specified co-ordinates into a rect.    }
  900.         FrameRect(Rectangle);                                            {Draw the group's box                            }
  901.         if Str <> '' then                                                    {If a string was included as the group's title, it    }
  902.             begin                                                        {    will be centered at the top…                    }
  903.                 Width := StringWidth(Str);                                    {Calculate the text's width in pixels                }
  904.                 TextRect.left := (Rectangle.left + Rectangle.right) div 2 - (Width div 2) - 2;    {Calculate a rectangle so that it    }
  905.                 TextRect.right := TextRect.left + Width + 4;                    {    fits on the top edge of the group's box.  It's    }
  906.                 TextRect.top := Rectangle.top - 8;                            {    wide enough for the title, plus a 2 pixel        }
  907.                 TextRect.bottom := TextRect.top + 16;                        {    border on each side.                        }
  908.                 TextBox(ptr(ord(@Str) + 1), length(Str), TextRect, teJustCenter);    {Draw the group's title                    }
  909.             end                                                            {                                                }
  910.     end;                                                                {                                                }
  911.  
  912.  
  913. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   1 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  914. {    This routine draws all the text and lines in demo window 1.  It is called when first creating the window and when    }
  915. {    the window needs to be refreshed.  Note that objects that are created by Tools Plus are refreshed automatically.    }
  916.     procedure DrawWindow1Contents;
  917.     begin
  918.                                                                     { C o m m e n t s    -    -    -    -    -    -    -    -    }
  919.         PenPat(Gray);                                                    {Use gray pattern for drawing framing boxes        }
  920.         TextFont(Geneva);                                                {Draw all comments using Geneva 9pt, plain        }
  921.         TextSize(9);                                                    {    style.                                        }
  922.         TextFace([]);                                                    {                                                }
  923.                                                                     {Comments for left list box…                    }
  924.         TextInBox('This left text list uses the standard system font, just like normal list boxes.', 38, 108, 236, 140, teJustLeft, false);
  925.                                                                     {Comments for right list box…                    }
  926.         TextInBox('This one uses Geneva 9pt.  Each list box can have its own font.', 295, 108, 416, 150, teJustLeft, false);
  927.                                                                     {Comments for Cursor Zones…                    }
  928.         TextInBox('This is a "Plus Cursor" zone.  The cursor changes when entering this area.', 275, 150, 400, 189, teJustCenter, true);
  929.         TextInBox('This is a "Cross Cursor" zone.  The cursor changes when entering this area.', 275, 193, 400, 232, teJustCenter, true);
  930.                                                                     {Comments for mini-buttons…                    }
  931.         TextInBox('These buttons are drawn in bold Geneva 9pt.  Many different fonts, sizes and styles can be used.', 120, 140, 240, 190, teJustLeft, false);
  932.         PenSize(3, 3);                                                    {Make the pen 3x3 pixels for a fatter line        }
  933.         GroupBox('', 14, 137, 242, 192);                                {Draw a gray, fat box around the mini buttons    }
  934.                                                                     {Comment at bottom of the window…            }
  935.         TextInBox('Double-click a radio button or a line in a list box to mean “select this and click ‘OK’.”  (Note that the OK button flashes.)  This OPTION is easily implemented.', 5, 290, 420, 320, teJustCenter, false);
  936.  
  937.  
  938.                                                                     { L i s t   B o x   T i t l e s    -    -    -    -    -    -    }
  939.         TextFont(systemFont);                                            {Set the window's font to Chicago 12pt.            }
  940.         TextSize(12);                                                    {                                                }
  941.         MoveTo(5, 19);                                                    {Draw the word 'Left' at local co-ordinates 5,19    }
  942.         DrawString('Left:');                                                {    for the left list box.                            }
  943.         MoveTo(253, 19);                                                {Draw the word 'Right' at local co-ord 253,19        }
  944.         DrawString('Right:');                                            {    for the right list box.                        }
  945.  
  946.                                                                     { R a d i o   B u t t o n   G r o u p ' s   T i t l e    -    }
  947.         PenNormal;                                                        {Reset pen pattern to black, and pen size to 1x1}
  948.         GroupBox('Choose', 165, 212, 231, 273);                        {Draw a box around the radio button group and    }
  949.     end;                                                                {    give the group a title.                        }
  950.  
  951.  
  952. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   2 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  953. {    This routine draws all the text and lines in demo window 2.  It is called when first creating the window and when    }
  954. {    the window needs to be refreshed.  Note that objects that are created by Tools Plus are refreshed automatically.    }
  955.     procedure DrawWindow2Contents;
  956.         var
  957.             Rectangle: rect;                                                {Rectangle for drawing comments (text)            }
  958.     begin
  959.                                                                     { C o m m e n t   a b o v e   f i e l d s    -    -    -    }
  960.         TextFont(Geneva);                                                {Draw all comments using Geneva 9pt.            }
  961.         TextSize(9);                                                    {                                                }
  962.         PenPat(Gray);                                                    {Any line drawing will be done with a gray pattern}
  963.         TextInBox(concat('Click the "zoom box" to zoom between the standard and user co-ordinates.', ReturnKey, ReturnKey, 'The scroll bars don''t actually scroll anything in this demo.  But notice that they are automatically repositioned when you resize the window.'), 10, 2, 191, 95, teJustLeft, false);
  964.  
  965.                                                                     { C o m m e n t   f o r   f i r s t   f i e l d    -    -    -    }
  966.         TextInBox('The first field is "length limited."  It accepts a maximum of 30 characters, (the length of the field), and does not scroll or require word-wrap.', 220, 15, 375, 77, teJustLeft, false);
  967.         SetRect(Rectangle, 215, 10, 380, 82);                            {Define the outline around the comment            }
  968.         FrameRect(Rectangle);                                            {Draw a gray box around the comment            }
  969.         MoveTo(215, 46);                                                {Draw a gray line from the first field to the box    }
  970.         LineTo(195, 105);                                                {    that was previously completed.                }
  971.  
  972.                                                                     { C o m m e n t   f o r   s e c o n d   f i e l d    -    -    }
  973.         TextInBox('The second field is a "single-line" editing field.  It scrolls to keep the selection in view, and does not require word wrap.', 220, 97, 375, 146, teJustLeft, false);
  974.         SetRect(Rectangle, 215, 92, 380, 151);                            {Define the outline around the comment            }
  975.         FrameRect(Rectangle);                                            {Draw a gray box around the comment            }
  976.         MoveTo(215, 126);                                                {Draw a gray line from the second field to the    }
  977.         LineTo(195, 126);                                                {    box that was previously completed.            }
  978.  
  979.                                                                     { C o m m e n t   f o r   t h i r d   f i e l d    -    -    -    }
  980.         TextInBox('The third field is a "multiple-line" editing field.  It scrolls to keep the selection in view, and uses word wrap to break long words.', 220, 166, 375, 215, teJustLeft, false);
  981.         SetRect(Rectangle, 215, 161, 380, 220);                        {Define the outline around the comment            }
  982.         FrameRect(Rectangle);                                            {Draw a gray box around the comment            }
  983.         MoveTo(215, 207);                                                {Draw a gray line from the third field to the box    }
  984.         LineTo(195, 148);                                                {    that was previously completed.                }
  985.  
  986.                                                                     { C o m m e n t s   a t   b o t t o m    -    -    -    -    }
  987.         TextInBox('Try editing the text in the fields (above).  The Edit menu automatically works with the active field (check out the Undo!)', 10, 220, 200, 260, teJustLeft, false);
  988.         TextInBox('Notice that each editing field can have its own font!', 220, 235, 375, 260, teJustLeft, false);
  989.     end;
  990.  
  991.  
  992. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   3 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  993. {    This routine draws all the text and lines in demo window 3.  It is called when first creating the window and when    }
  994. {    the window needs to be refreshed.  Note that objects that are created by Tools Plus are refreshed automatically.    }
  995.     procedure DrawWindow3Contents;
  996.     begin
  997.         TextFont(Geneva);                                                {Comment at top of window (drawn in Geneva    }
  998.         TextSize(9);                                                    {    9pt)…                                        }
  999.         TextInBox('This demo simulates MIDI Interface settings.  Click on an icon to select it.', 10, 100, 230, 200, teJustCenter, false);
  1000.         DrawIcon(PrinterIcon, 20, 32, enabled, MidiPort = PrinterIcon);    {Redraw the printer and modem icons as        }
  1001.         DrawIcon(ModemIcon, 65, 32, enabled, MidiPort = ModemIcon);{    currently selected.                            }
  1002.         TextFont(systemFont);                                            {Box and title around icon group and radio        }
  1003.         TextSize(12);                                                    {    button group (drawin in Chicago 12 pt.)…    }
  1004.         GroupBox('Port', 7, 17, 111, 80);                                {Draw a box around the Printer and Modem        }
  1005.                                                                     {    icons, and give the group a title.            }
  1006.         GroupBox('Speed', 128, 17, 231, 80);                            {Draw a box around the interface Speed radio    }
  1007.     end;                                                                {    buttons, and give the group a title.            }
  1008.  
  1009.  
  1010. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   4 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1011. {    This routine draws all the text in demo window 4.  It is called when first creating the window and when the window    }
  1012. {    needs to be refreshed.                                                                                }
  1013.     procedure DrawWindow4Contents;
  1014.     begin
  1015.         MoveTo(10, 21);                                                {This window has been previously set to draw    }
  1016.         DrawString('A lengthy process is being simulated.');                {    characters using Chicago 12 pt.  Simply        }
  1017.         MoveTo(10, 85);                                                {    display the message.                        }
  1018.         DrawString(concat('Type ', chr(CommandMark), '-. to cancel the simulation.'));    {                                }
  1019.     end;                                                                {                                                }
  1020.  
  1021.  
  1022. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   5 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1023. {    This routine draws all the text and pictures in demo window 5.  It is called when first creating the window and        }
  1024. {    when the window needs to be refreshed.  This routine has the following unique routines:                            }
  1025. {        • Color-independent drawing (doesn't care about the monitor's settings)                                        }
  1026. {        • Color-dependent drawing (different drawing dependent on number of colors, grays, or if black & white)        }
  1027. {        • Multiple-monitor compatibility (each monitor can have different settings)                                    }
  1028. {    The color PICTure looks good only in 256 colors, but it also looks good in 256 shades of gray as well as 16        }
  1029. {    shades of gray (8 bit and 4 bit gray).  So this demo decides which PICTure to draw depending on the monitor's    }
  1030. {    settings.                                                                                                        }
  1031. {        NOTE:  Tools Plus may not recognize if you change your monitor settings while running your application in    }
  1032. {    the development environment.  It will recognize the change when your application is compiled to be a stand-        }
  1033. {    alone (double-clickable) application.                                                                            }
  1034.     procedure DrawWindow5Contents;
  1035.         var
  1036.             TheScreen: integer;                                            {Screen counter for multiple-screen drawing        }
  1037.             hPicture: PicHandle;                                            {Handle to a PICTure resource                    }
  1038.             viewRect: rect;                                                {Viewing rectangle for the picture                }
  1039.     begin
  1040.                                                                     { C o l o r   I n d e p e n d e n t   D r a w i n g :    -    }
  1041.                                                                     {Drawing that doesn't care about the monitor's    }
  1042.                                                                     {    setting can be done before or after the        }
  1043.                                                                     {    color-dependent drawing.                    }
  1044.         TextInBox(concat('This window demonstrates color-dependent, color-independent, and multiple-screen drawing.  Use the Monitors desk accessory to change the monitor’s settings.', ReturnKey, '  If you have two monitors, drag the window across so that half is on each screen.'), 10, 5, 300, 70, teJustLeft, false);
  1045.  
  1046.                                                                     { C o l o r   D e p e n d e n t   D r a w i n g :        -    }
  1047.                                                                     {The following code is for drawing that depends    }
  1048.                                                                     {    on the number of available colors, shades    }
  1049.                                                                     {    of gray, or if the monitor is set to Black &    }
  1050.                                                                     {    White.  It also makes the routine multiple-    }
  1051.                                                                     {    monitor compatible.                            }
  1052.         for TheScreen := 1 to NumberOfScreens do                    {Repeat drawing once for each logical screen    }
  1053.             begin                                                        {    (monitor with different settings)…            }
  1054.                 BeginUpdateScreen(TheScreen);                            {Begin the update for this logical screen.  All    }
  1055.                                                                     {    drawing is limited (clipped) to the one logical    }
  1056.                                                                     {    screen.                                        }
  1057.                 if ((ScreenDepth >= 8) or ((ScreenDepth = 4) and (not ScreenHasColors))) then    {Use the color pictures    }
  1058.                     hPicture := GetPicture(ColorPICT)                        {    only if 256 colors or 16 shades of gray are    }
  1059.                 else                                                        {    available (or better).  Otherwise, use the    }
  1060.                     hPicture := GetPicture(BlackAndWhitePICT);                {    Black & White equivalent.                    }
  1061.                 viewRect := hPicture^^.picFrame;                            {Determine the picture's framing rectangle        }
  1062.                                                                     {The picture's rectangle is in the local window    }
  1063.                                                                     {    co-ordinates of the application that created    }
  1064.                                                                     {    it, so convert it to the local co-ordinates of    }
  1065.                 OffsetRect(viewRect, -viewRect.left, -viewRect.top);        {    this demo window.                            }
  1066.                                                                     {Offset the picture's rectangle such that it is    }
  1067.                 OffsetRect(viewRect, 30, 90);                                {    drawn below the descriptive text.            }
  1068.                 DrawPicture(hPicture, viewRect);                            {Draw the picture in its destination rectangle.    }
  1069.                 ReleaseResource(handle(hPicture));                        {Release the resource to conserve memory        }
  1070.                 EndUpdateScreen;                                            {End the update to the current logical screen    }
  1071.             end                                                            {                                                }
  1072.     end;                                                                {                                                }
  1073.  
  1074.  
  1075. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   6 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1076. {    Dynamic Alerts take care of all drawing, so you don't have to write any code for it.  This routine is here for        }
  1077. {    cosmetic reasons only, and you can get rid of it if you want.                                                        }
  1078.     procedure DrawWindow6Contents;
  1079.     begin
  1080.     end;
  1081.  
  1082.  
  1083. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   7 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1084. {    This routine draws all the text and lines in demo window 7.  It is called when first creating the window and when    }
  1085. {    the window needs to be refreshed.                                                                                }
  1086.     procedure DrawWindow7Contents;
  1087.         var
  1088.             Rectangle: rect;                                                {Rectangle for drawing comments (text)            }
  1089.     begin
  1090.                                                                     { C o m m e n t s   b e s i d e   P o p - U p   M e n u s}
  1091.                                                                     {All comments use Geneva 9pt, as set when    }
  1092.                                                                     {    this window was first opened.                }
  1093.         PenPat(Gray);                                                    {Any line drawing will be done with a gray pattern}
  1094.  
  1095.                                                                     { C o m m e n t   f o r   f i r s t   m e n u    -    -    -    }
  1096.         TextInBox('This is a standard Pop-Up Menu.  Nothing special here, except that it’s really easy to do.', 235, 15, 380, 51, teJustLeft, false);
  1097.         SetRect(Rectangle, 230, 12, 385, 55);                            {Define the outline around the comment            }
  1098.         FrameRect(Rectangle);                                            {Draw a gray box around the comment            }
  1099.         MoveTo(215, 26);                                                {Draw a gray line from the first menu to the box    }
  1100.         LineTo(230, 26);                                                {    completed above.                            }
  1101.  
  1102.                                                                     { C o m m e n t   f o r   s e c o n d   m e n u    -    -    }
  1103.         TextInBox('This Pop-Up Menu has icons.  But unlike System-7’s pop-ups, the selected item’s icon can appear in the pop-up box.', 235, 65, 380, 113, teJustLeft, false);
  1104.         SetRect(Rectangle, 230, 62, 385, 117);                            {Define the outline around the comment            }
  1105.         FrameRect(Rectangle);                                            {Draw a gray box around the comment            }
  1106.         MoveTo(220, 76);                                                {Draw a gray line from the second menu to the    }
  1107.         LineTo(230, 76);                                                {    box completed above.                        }
  1108.  
  1109.                                                                     { C o m m e n t   f o r   t h i r d   m e n u    -    -    -    }
  1110.         TextInBox('This Pop-Up Menu contains icons without any text.  It looks like a custom menu but it’s not.', 235, 125, 380, 161, teJustLeft, false);
  1111.         SetRect(Rectangle, 230, 122, 385, 165);                        {Define the outline around the comment            }
  1112.         FrameRect(Rectangle);                                            {Draw a gray box around the comment            }
  1113.         MoveTo(175, 136);                                                {Draw a gray line from the third menu to the box    }
  1114.         LineTo(230, 136);                                                {    completed above.                            }
  1115.  
  1116.                                                                     { C o m m e n t   f o r   f o u r t h   m e n u    -    -    }
  1117.         TextInBox('This is a “Pop-Down” menu.  It’s like an on-screen pull-down menu, and is usually used to “do something now.”', 235, 185, 380, 233, teJustLeft, false);
  1118.         SetRect(Rectangle, 230, 182, 385, 237);                        {Define the outline around the comment            }
  1119.         FrameRect(Rectangle);                                            {Draw a gray box around the comment            }
  1120.         MoveTo(220, 196);                                                {Draw a gray line from the fourth menu to the    }
  1121.         LineTo(230, 196);                                                {    box completed above.                        }
  1122.  
  1123.                                                                     { C o m m e n t   f o r   f i f t h   m e n u    -    -    -    }
  1124.         TextInBox('Pop-Up Menus can use any font and size, and can be auto-sized for a perfect look.', 235, 245, 380, 281, teJustLeft, false);
  1125.         SetRect(Rectangle, 230, 242, 385, 285);                        {Define the outline around the comment            }
  1126.         FrameRect(Rectangle);                                            {Draw a gray box around the comment            }
  1127.         MoveTo(150, 246);                                                {Draw a gray line from the fifth menu to the box    }
  1128.         LineTo(230, 246);                                                {    box completed above.                        }
  1129.     end;                                                                {                                                }
  1130.  
  1131.  
  1132. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   8 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1133. {    This routine draws all the text and lines in demo window 8.  Tools Plus takes care of all the button drawing.  The    }
  1134. {    band at the top of this window demonstrates how to make a tool bar in a window.                                    }
  1135.     procedure DrawWindow8Contents;
  1136.         var
  1137.             TheScreen: integer;                                            {Screen counter for multiple-screen drawing        }
  1138.             ToolBarRect: rect;                                            {Rectangle for drawing toolbar                    }
  1139.     begin
  1140.                                                                     { D r a w   T o o l B a r   B a c k g r o u n d            }
  1141.         SetRect(ToolBarRect, -1, -1, 473, 29);                            {Define the toolbar's rectangle                    }
  1142.                                                                     {Draw the toolbar gray if the monitor is set to    }
  1143.                                                                     {    4-bits or better…                            }
  1144.         for TheScreen := 1 to NumberOfScreens do                    {Repeat drawing once for each logical screen    }
  1145.             begin                                                        {    (monitor with different settings)…            }
  1146.                 PenColorNormal;                                            {PEN: 1 x 1 size, black color, patCopy mode    }
  1147.                 BeginUpdateScreen(TheScreen);                            {Begin the update for this logical screen.  All    }
  1148.                                                                     {    drawing is limited (clipped) to the one logical    }
  1149.                                                                     {    screen.                                        }
  1150.                 if ScreenDepth >= 4 then                                    {If this logical screen is set to a depth of 4-bits    }
  1151.                     begin                                                    {    or more (16 colors/grays)…                    }
  1152.                         RGBForeColor(ToolBarGray);                            {                                                }
  1153.                         PaintRect(ToolBarRect);                                {Paint the toolbar the medium dark gray            }
  1154.                     end;                                                        {                                                }
  1155.                 EndUpdateScreen;                                            {End the update to the current logical screen    }
  1156.             end;                                                            {                                                }
  1157.         PenColorNormal;                                                {PEN: 1 x 1 size, black color, patCopy mode    }
  1158.         FrameRect(ToolBarRect);                                        {Draw a black 1-pixel frame around the toolbar    }
  1159.  
  1160.                                                                     { B u t t o n ' s   V a l u e s                        }
  1161.         ActionInWindow8_DrawToolBarValue;                            {Draw the value in the window's tool bar            }
  1162.         ActionInWindow8_DrawGlobeValue;                            {Draw the globe button's value                    }
  1163.  
  1164.         TextFont(Geneva);                                                {All comments are drawn using Geneva font        }
  1165.         TextSize(12);                                                    {One comment is drawin in Geneva 9pt…        }
  1166.         MoveTo(6, 134);                                                {                                                }
  1167.         DrawString('Picture Buttons are very versatile.  You define their look and behavior.');    {                        }
  1168.         PenPat(Gray);                                                    {Any line drawing will be done with a gray pattern}
  1169.         MoveTo(0, 118);                                                {Draw gray line dividing upper and lower part of    }
  1170.         LineTo(472, 118);                                                {    the window.                                    }
  1171.         TextSize(9);                                                    {All other comments use Geneva 9pt.            }
  1172.  
  1173.                                                                     { C o m m e n t   f o r   A r r o w   B u t t o n s    -    }
  1174.         TextInBox('These buttons use an icon for each stage, giving you absolute control over their appearance.', 10, 41, 155, 80, teJustLeft, false);
  1175.         MoveTo(120, 29);                                                {Draw a gray line from this comment to the        }
  1176.         LineTo(120, 40);                                                {    buttons it refers to.                            }
  1177.  
  1178.                                                                     { C o m m e n t   f o r   A l i g n m e n t   B u t t o n s    }
  1179.         TextInBox('These “SICN 3D” buttons are available in two sizes.  They use a single icon each.  Tools Plus does all the 3D drawing.  Activate another window and see how they look disabled.', 167, 41, 358, 110, teJustLeft, false);
  1180.         MoveTo(218, 29);                                                {Draw a gray line from this comment to the        }
  1181.         LineTo(218, 40);                                                {    buttons it refers to.                            }
  1182.         MoveTo(322, 29);                                                {                                                }
  1183.         LineTo(322, 40);                                                {                                                }
  1184.  
  1185.                                                                     { C o m m e n t   f o r   U t i l i t y   B u t t o n s    -    }
  1186.         TextInBox('This pair of buttons behaves as one control.  Continuous events are generated while the mouse button is held down.', 368, 41, 471, 118, teJustLeft, false);
  1187.         MoveTo(450, 29);                                                {Draw a gray line from this comment to the        }
  1188.         LineTo(450, 40);                                                {    buttons it refers to.                            }
  1189.  
  1190.                                                                     { C o m m e n t   f o r   P l a i n   I c o n   B u t t o n s    }
  1191.         TextInBox('Use picture buttons for clickable icons.', 19, 191, 111, 216, teJustLeft, false);    {                    }
  1192.  
  1193.                                                                     { C o m m e n t   f o r   T a p e   D e c k   B u t t o n s    }
  1194.         TextInBox('Professional looking controls are easy!', 20, 281, 117, 306, teJustLeft, false);    {                    }
  1195.  
  1196.                                                                     { C o m m e n t   f o r   S c r o l l i n g   B u t t o n    }
  1197.         TextInBox('These buttons have “values” associated with them.  You can raise/lower the value by clicking on opposite sides of the button.  The left button uses only 1 icon!', 204, 154, 398, 203, teJustLeft, false);
  1198.         MoveTo(147, 158);                                                {                                                }
  1199.         DrawString('Step');                                                {                                                }
  1200.         MoveTo(172, 158);                                                {                                                }
  1201.         DrawString('Scroll');                                            {                                                }
  1202.  
  1203.                                                                     { C o m m e n t   f o r   D u a l -  S t a g e   B u t t o n    }
  1204.         TextInBox('These dual-stage buttons toggle when selected.', 221, 243, 342, 268, teJustLeft, false);    {        }
  1205.     end;
  1206.  
  1207.  
  1208. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   9 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1209. {    This routine draws the contents of demo window 9 (the Tool Bar).  In this demo, the only thing the Tool Bar needs    }
  1210. {    is to be painted with the correct color (gray when the monitor is set to 4 bits or higher).                            }
  1211.     procedure DrawWindow9Contents;
  1212.         var
  1213.             ToolBarRect: rect;                                            {Rectangle for drawing toolbar                    }
  1214.     begin
  1215.                                                                     { P a i n t   T o o l B a r   G r a y                    }
  1216.         if ScreenDepth >= 4 then                                        {If the main minitor is set to a depth of 4-bits or    }
  1217.             begin                                                        {    more (16 colors/grays), paint the tool bar…    }
  1218.                 RGBForeColor(ToolBarGray);                                {Set the foregound color to gray                    }
  1219.                 SetRect(ToolBarRect, 0, 0, 32000, 32000);                    {Define the toolbar's rectangle (who cares how    }
  1220.                                                                     {    big it really is?  All drawing is limited to the    }
  1221.                                                                     {    Tool Bar).                                    }
  1222.                 PaintRect(ToolBarRect);                                    {Paint the tool bar the medium dark gray            }
  1223.             end                                                            {                                                }
  1224.     end;                                                                {                                                }
  1225.  
  1226.  
  1227. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   10 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1228. {    This floating palette contains only Tools Plus objects, so there is no need to draw anything in this window.  This    }
  1229. {    routine is here for cosmetic reasons only, and you can get rid of it if you want.                                    }
  1230.     procedure DrawWindow10Contents;
  1231.     begin
  1232.     end;
  1233.  
  1234.  
  1235. { D r a w   C o n t e n t s   o f   D e m o   W i n d o w   11 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1236. {    This floating palette contains only Tools Plus objects, so there is no need to draw anything in this window.  This    }
  1237. {    routine is here for cosmetic reasons only, and you can get rid of it if you want.                                    }
  1238.     procedure DrawWindow11Contents;
  1239.     begin
  1240.     end;
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251. { R e f r e s h   A   W i n d o w : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1252. {    This routine is called in response to a "doRefresh" event.  It redraws the contents of a window.  Note that            }
  1253. {    objects such as Scroll Bars, List Boxes, Buttons and Editing Fields are updated automatically.                    }
  1254. {        You should account for each of your application's windows in a routine such as this one, even if they are        }
  1255. {    modal.  Modal windows may need updating if the Mac running your application is running a screen saver.  When    }
  1256. {    the screen saver is woken up, chances are that it will demand that all windows be refreshed.                        }
  1257.     procedure RefreshWindow;
  1258.     begin
  1259.         CurrentWindow(Poll.Window);                                    {Make the affected window the current grafPort.    }
  1260.                                                                     {    That means that all drawing operations will    }
  1261.                                                                     {    be done on that window.                    }
  1262.         BeginUpdate(WindowPointer(Poll.Window));                    {Restrict drawing to within the area that needs    }
  1263.                                                                     {    refreshing.  Any drawing done outside this    }
  1264.                                                                     {    area is ignored.                                }
  1265.         case Poll.Window of                                            {Depending on which window needs to be        }
  1266.             DemoWindow1:                                                 {    refreshed, call the appropriate routine to do    }
  1267.                 DrawWindow1Contents;                                    {    the required drawing…                        }
  1268.             DemoWindow2:                                                 {                                                }
  1269.                 DrawWindow2Contents;                                    {                                                }
  1270.             DemoWindow3:                                                  {                                                }
  1271.                 DrawWindow3Contents;                                    {                                                }
  1272.             DemoWindow4:                                                  {                                                }
  1273.                 DrawWindow4Contents;                                    {                                                }
  1274.             DemoWindow5:                                                  {                                                }
  1275.                 DrawWindow5Contents;                                    {                                                }
  1276.             DemoWindow6:                                                  {                                                }
  1277.                 DrawWindow6Contents;                                    {                                                }
  1278.             DemoWindow7:                                                  {                                                }
  1279.                 DrawWindow7Contents;                                    {                                                }
  1280.             DemoWindow8:                                                  {                                                }
  1281.                 DrawWindow8Contents;                                    {                                                }
  1282.             ToolBarWindow:                                                  {                                                }
  1283.                 DrawWindow9Contents;                                    {                                                }
  1284.             VerticalPalette:                                                 {                                                }
  1285.                 DrawWindow10Contents;                                    {                                                }
  1286.             HorizontalPalette:                                             {                                                }
  1287.                 DrawWindow11Contents;                                    {                                                }
  1288.         end;
  1289.         EndUpdate(WindowPointer(Poll.Window));                        {End the update for the window, and tell the Mac    }
  1290.                                                                     {    you've finished updating this window (ie:    }
  1291.                                                                     {    clear the window's update region).            }
  1292.         CurrentWindowReset;                                            {Reset the active window to also be the    }
  1293.                                                                     {    current window (all drawing will resume on    }
  1294.     end;                                                                {    the active window).                            }
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305. {  C r e a t e   D e m o   W i n d o w s : =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =    }
  1306. {    The following routines are used to create each of the demo windows and their contents.  These routines are        }
  1307. {    invoked when the user selects an item in the Demos menu.  A couple of these windows are opened automatically    }
  1308. {    by the 'PrepareTheDemo' routine when this program starts up.                                                    }
  1309.  
  1310.  
  1311. { C r e a t e   D e m o   W i n d o w   1 :    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    }
  1312. {    This window demonstrates how Tools Plus works with  List Boxes, Buttons (radio buttons, check boxes and        }
  1313. {    push buttons), and Cursor Zones.                                                                                }
  1314. {        When playing around with this window, try the following things:                                                }
  1315. {            • double-click a line in a List Box and notice how it translates to 'select this line and OK'                    }
  1316. {            • press the Enter or Return key to activate the default OK button                                        }
  1317. {            • activate another window and notice all the buttons and list boxes get disabled.  Also notice that the        }
  1318. {               black outline around the default OK button gets dimmed out too!                                        }
  1319. {    TIP:  To make this window appear to fill in as quickly as possible, we don't populate the list boxes until the end!    }
  1320.     procedure OpenDemoWindow1;
  1321.     begin
  1322.                                                                     {Open the window (it automatically shifts down    }
  1323.                                                                     {    to compensate for an open Tool Bar, and its    }
  1324.                                                                     {    position is 'tiled')…                            }
  1325.         WindowOpen(DemoWindow1, 0, 0, 425, 320, 'Lists, Buttons and Cursor Zones', noGrowDocProc + wTile, GoAway, NotModal);
  1326.                                                                     { Left List Box:    -    -    -    -    -    -    -    -    }
  1327.         TextFont(systemFont);                                            {Create an empty list box.  Its font will be the    }
  1328.         TextSize(12);                                                    {    window's current font: Chicago 12 pt.        }
  1329.         NewListBox(LeftList, 40, 8, 220, 104, lOnlyOne);                {                                                }
  1330.                                                                     { Right List Box:    -    -    -    -    -    -    -    }
  1331.         TextFont(Geneva);                                                {Create a second empty list box.  This one will    }
  1332.         TextSize(9);                                                    {    use Geneva 9pt to show that a different        }
  1333.         NewListBox(RightList, 295, 8, 400, 104, lOnlyOne);                {    font can be used per list box.                }
  1334.                                                                     { B u t t o n s :    -    -    -    -    -    -    -    -    }
  1335.         TextFace([bold]);                                                {Buttons will be drawn in bold Geneva 9pt.        }
  1336.                                                                     {Create a set of mini-fonts using Geneva 9pt in    }
  1337.                                                                     {    bold typeface.  This demonstrates the use    }
  1338.                                                                     {    of a second font for buttons.                }
  1339.         NewButton(MiniButton1, 20, 150, 35, 166, '1', pushButProc + useWFont, enabled, notSelected);    {            }
  1340.         NewButton(MiniButton2, 40, 150, 55, 166, '2', pushButProc + useWFont, enabled, notSelected);    {            }
  1341.         NewButton(MiniButton3, 60, 150, 75, 166, '3', pushButProc + useWFont, enabled, notSelected);    {            }
  1342.         NewButton(MiniButton4, 80, 150, 95, 166, '4', pushButProc + useWFont, enabled, notSelected);    {            }
  1343.         NewButton(MiniButton5, 100, 150, 115, 166, '5', pushButProc + useWFont, enabled, notSelected);    {            }
  1344.                                                                     {Create a set of check boxes using the System    }
  1345.                                                                     {    font (Chicago 12)…                            }
  1346.         NewButton(CheckBox1, 20, 220, 117, 236, 'First Choice', checkBoxProc, enabled, notSelected);    {            }
  1347.         NewButton(CheckBox2, 20, 236, 133, 252, 'Second Choice', checkBoxProc, enabled, selected);    {            }
  1348.         NewButton(CheckBox3, 20, 252, 134, 268, 'Two And Three', checkBoxProc, enabled, selected);    {            }
  1349.                                                                     {Create a set of radio buttons using the System    }
  1350.                                                                     {    font (Chicago 12)…                            }
  1351.         NewButton(RadioButton1, 170, 220, 214, 236, 'One', radioButProc, enabled, selected);                {            }
  1352.         NewButton(RadioButton2, 170, 236, 216, 252, 'Two', radioButProc, enabled, notSelected);            {            }
  1353.         NewButton(RadioButton3, 170, 252, 226, 268, 'Three', radioButProc, enabled, notSelected);        {            }
  1354.                                                                     {Create the 'Cancel' push-button…                }
  1355.         NewButton(CancelButton, 275, 250, 335, 270, 'Cancel', pushButProc, enabled, notSelected);        {            }
  1356.                                                                     {Create the 'OK' push-button.  This is the        }
  1357.                                                                     {    window's default button, and it is selected    }
  1358.                                                                     {    automatically when you press Return or        }
  1359.         NewButton(OkButton, 350, 250, 410, 270, 'OK', DefaultButton, enabled, notSelected);                {    Enter.    }
  1360.  
  1361.         DrawWindow1Contents;                                        {Draw the rest of the objects in this demo        }
  1362.                                                                     {    window.  All Tools Plus objects are auto-    }
  1363.                                                                     {    matically updated when a window needs to    }
  1364.                                                                     {    be refreshed, such as when you bring it to    }
  1365.                                                                     {    the front to make it active.                    }
  1366.                                                                     {        Non-Tools Plus objects (ie: those you    }
  1367.                                                                     {    create) have to be redrawn separately in    }
  1368.                                                                     {    response to a doRefresh event, so it's a    }
  1369.                                                                     {    good idea to keep them in a separate        }
  1370.                                                                     {    routine.                                        }
  1371.  
  1372.     { T i m e   c o n s u m i n g   t h i n g s …                                                                            }
  1373.     {    The following time-consuming things were saved for the end of the routine because it makes the window        }
  1374.     {    appear to be filled in faster, particularly on slower Macs like the Plus, Classic, or LC.  You don't have to        }
  1375.     {    follow the same concept when you write your own applications.                                                }
  1376.                                                                     { C u r s o r   T a b l e   &   Z o n e s:    -    -    -    }
  1377.         NewCursorTable(1, arrowCursor);                                {Create Cursor Table number 1.  The standard    }
  1378.                                                                     {    Arrow cursor is the default for this table.    }
  1379.         CursorZone(1, 1, plusCursor, 275, 150, 400, 189);                {Add two Cursor Zones to the Cursor Table.        }
  1380.         CursorZone(1, 2, crossCursor, 275, 193, 400, 232);                {    When the cursor is in these zones, it will    }
  1381.                                                                     {    automatically change to the specified        }
  1382.                                                                     {    cursor shape.                                }
  1383.         UseCursorTable(1);                                                {The current window will use Cursor Table no 1.    }
  1384.                                                                     {    Note that a cursor table exists                }
  1385.                                                                     {    independently of windows.  In fact, several    }
  1386.                                                                     {    windows can each use the same cursor        }
  1387.                                                                     {    table.  It is not necessary to create a cursor    }
  1388.                                                                     {    table each time you want a window to use it.    }
  1389.                                                                     {    You just use the UseCursorTable routine to    }
  1390.                                                                     {    make a window use a cursor table.            }
  1391.                                                                     { F i l l   L i s t   B o x e s :    -    -    -    -    -    -    }
  1392.         DrawListBox(LeftList, off);                                        {Turn list box drawing off for both boxes.  The    }
  1393.         DrawListBox(RightList, off);                                    {    contents will be drawn later.  If you don't    }
  1394.                                                                     {    turn list box drawing off while adding lines,    }
  1395.                                                                     {    you will see each line being added, one at a    }
  1396.                                                                     {    time.  This way, you see all the lines appear    }
  1397.                                                                     {    at once.                                    }
  1398.         SetListBoxText(LeftList, 1, 'Bill Arlington, Shipping & Receiving');{Fill the lines in the left list box.  You can fill    }
  1399.         SetListBoxText(LeftList, 2, 'Gail Force, Social Director');        {    these lines in any order you want.  Notice    }
  1400.         SetListBoxText(LeftList, 3, 'Bill Gates, Comedy Relief');        {    the longer lines are compressed (the        }
  1401.         SetListBoxText(LeftList, 4, 'Ron Martin, Art & Graphics');        {    characters are closer together) when using    }
  1402.         SetListBoxText(LeftList, 5, 'Samantha Moore, Connectivity');    {    System 7.  Tools Plus automatically            }
  1403.         SetListBoxText(LeftList, 6, 'Mike Simms, Design');                {    appends the ellipsis (…) if the line's text is    }
  1404.         SetListBoxText(LeftList, 7, 'Sam Strong, Design');                {    too long to see in the list.                    }
  1405.         SetListBoxText(LeftList, 8, 'Linda Tyler, Drafting');                {                                                }
  1406.         SetListBoxText(LeftList, 9, 'Margaret Victor, Drafting');            {                                                }
  1407.         SetListBoxText(RightList, 1, 'Art & Graphics');                    {Fill in the lines in the right list box.  The Tools    }
  1408.         SetListBoxText(RightList, 2, 'Connectivity');                    {    Plus User Manual describes how you can    }
  1409.         SetListBoxText(RightList, 3, 'Comedy Relief');                    {    populate a list box and have the lines in        }
  1410.         SetListBoxText(RightList, 4, 'Design');                            {    alphabetic order.                            }
  1411.         SetListBoxText(RightList, 5, 'Drafting');                            {                                                }
  1412.         SetListBoxText(RightList, 6, 'Shipping & Receiving');            {                                                }
  1413.         SetListBoxText(RightList, 7, 'Social Director');                    {                                                }
  1414.         SetListBoxLine(LeftList, 2, on);                                    {Select the left list's second line by default.        }
  1415.         DrawListBox(LeftList, on);                                        {Turn on line drawing for both list boxes. Their    }
  1416.         DrawListBox(RightList, on);                                        {    contents are drawn by this process.        }
  1417.         EnableMenu(FileMenu, CloseItem, enabled);                    {Enable the File menu's Close command, now    }
  1418.     end;                                                                {    that there's a window to close.                }
  1419.  
  1420.  
  1421. { C r e a t e   D e m o   W i n d o w   2 :    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    }
  1422. {    This window demonstrates how Tools Plus works with  Editing Fields, Window Zooming and Scroll Bars.  Please    }
  1423. {    note that although this window has scroll bars, the demo doesn't actually scroll anything.  Notice that when you    }
  1424. {    click the window's zoom box, or when you resize the window by using the size box, that the scroll bars are        }
  1425. {    automatically moved to accommodate the window's new size.                                                    }
  1426. {        When playing around with this window, try the following things:                                                }
  1427. {            • click the window's zoom box to zoom between the standard co-ordinates and the user-defined ones    }
  1428. {            • use the size box to resize the window.  Notice that the minimum and maximum size are controlled        }
  1429. {            • type in the first (length limited) field                                                                    }
  1430. {            • copy and paste test between another application or desk accessory and one of the fields                }
  1431.     procedure OpenDemoWindow2;
  1432.         var
  1433.             userRect, stdRect: rect;                                        {User co-ordinates and standard co-ordinates    }
  1434.                                                                     {    used for zooming one of the demo windows.    }
  1435.     begin
  1436.                                                                     { C r e a t e   t h e   W i n d o w :    -    -    -    -    }
  1437.                                                                     {Open the window (it automatically shifts down    }
  1438.                                                                     {    to compensate for an open Tool Bar, and its    }
  1439.                                                                     {    position is 'tiled')…                            }
  1440.         WindowOpen(DemoWindow2, 20, 58, 420, 338, 'Fields, Zooming and Scroll Bars', documentProc + ZoomBox + wTile, GoAway, NotModal);
  1441.         GetWindowZoom(userRect, stdRect);                            {Get the standard and user-defined co-ordinates}
  1442.                                                                     {    for Zooming the window (using zoom box)    }
  1443.         SetRect(userRect, 250, 100, 470, 320);                            {Define the window's 'user- defined' co- ords that}
  1444.                                                                     {    are used for Zooming the window when the    }
  1445.                                                                     {    zoom-box is clicked.                        }
  1446.         SetWindowZoom(userRect, stdRect);                            {Set the standard and user-defined co-ordinates}
  1447.                                                                     {    for Zooming.                                }
  1448.         SetWindowSizeLimits(220, 220, 400, 280);                        {Set the window's sizing limits:                    }
  1449.                                                                     {    minHoriz, minVert, maxHoriz, maxVert        }
  1450.                                                                     { S c r o l l   B a r s :    -    -    -    -    -    -    -    }
  1451.                                                                     {Create a right and bottom scroll bar for the        }
  1452.                                                                     {    window.  The last three parameters specify    }
  1453.                                                                     {    the min limit, current value, and max limit.    }
  1454.         NewScrollBar(RightBar, scrlRightEdge, scrlTopEdge, scrlRightEdge, scrlBottomEdge, enabled, 1, 5, 10);
  1455.         NewScrollBar(BottomBar, scrlLeftEdge, scrlBottomEdge, scrlRightEdge, scrlBottomEdge, enabled, 1, 50, 100);
  1456.  
  1457.                                                                     { E d i t i n g   F i e l d s :    -    -    -    -    -    -    }
  1458.         hField1^^ := 'Length limited field';                                {Specify the text that will be appear in each field.}
  1459.         hField2^^ := 'Single line editing field.';                            {                                                }
  1460.         hField3^^ := 'This is a multiple-line editing field which incorporates word wrap.';{                                    }
  1461.  
  1462.         TextFont(Monaco);                                                {First field uses Monaco 9pt font, and is length    }
  1463.         TextSize(9);                                                    {    limited.  That means that no more than 30    }
  1464.         FieldLengthLimit(on);                                            {    characters (the field's limit) can be typed or    }
  1465.         NewField(1, 10, 100, 191, 111, Handle(hField1), teBoxNoCR, teJustLeft);    {    pasted in the field.                }
  1466.         FieldLengthLimit(off);                                            {The remaining fields are not length limited        }
  1467.  
  1468.         TextFont(Geneva);                                                {Second field uses bold Geneva 9pt.  This field    }
  1469.         TextFace([bold]);                                                {    demonstrates a single-line editing field.        }
  1470.         NewField(2, 10, 120, 191, 132, Handle(hField2), teBoxNoCR, teJustLeft);    {                                    }
  1471.  
  1472.         TextFont(systemFont);                                            {Third field uses Chicago 12pt.  It demonstrates}
  1473.         TextSize(12);                                                    {    a multiple-line editing field with word wrap.    }
  1474.         TextFace([]);                                                    {                                                }
  1475.         NewField(3, 10, 141, 191, 189, Handle(hField3), teBoxCR, teJustLeft);    {                                        }
  1476.  
  1477.         ActivateField(1, teSelectEnd);                                    {Activate the first field, with the insertion point    }
  1478.                                                                     {    at the end of the text.                        }
  1479.         DrawWindow2Contents;                                        {Draw the rest of the objects in this demo        }
  1480.                                                                     {    window.  All Tools Plus objects are auto-    }
  1481.                                                                     {    matically updated when a window needs to    }
  1482.                                                                     {    be refreshed, such as when you bring it to    }
  1483.                                                                     {    the front to make it active.                    }
  1484.                                                                     {        Non-Tools Plus objects (ie: those you    }
  1485.                                                                     {    create) have to be redrawn separately in    }
  1486.                                                                     {    response to a doRefresh event, so it's a    }
  1487.                                                                     {    good idea to keep them in a separate        }
  1488.                                                                     {    routine.                                        }
  1489.  
  1490.         EnableMenu(FileMenu, CloseItem, enabled);                    {Enable the File menu's Close command, now    }
  1491.     end;                                                                {    that there's a window to close.                }
  1492.  
  1493.  
  1494. { C r e a t e   D e m o   W i n d o w   3 :    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    }
  1495. {    This window demonstrates shows how Tools Plus can draw icon families (in System 6 and System 7).  It also        }
  1496. {    provides an example how to use Cursor Zones to make icons click-sensitive.                                    }
  1497. {        When playing around with this window, try the following things:                                                }
  1498. {            • click either of the two icons                                                                            }
  1499. {            • if you have a color monitor, use the Monitors control panel to change the number of colors displayed    }
  1500. {            • if you have two monitors, set one to black and white and drag the window such that the icon is half on    }
  1501. {              a color screen and half on a black and white screen.  Tools Plus draws the icon perfectly.                }
  1502.     procedure OpenDemoWindow3;
  1503.     begin
  1504.                                                                     {Open the window (it automatically shifts down    }
  1505.                                                                     {    to compensate for an open Tool Bar, and its    }
  1506.                                                                     {    position is 'tiled')…                            }
  1507.         WindowOpen(DemoWindow3, 0, 0, 240, 142, 'Icons and Cursor Zones', noGrowDocProc + wTile, GoAway, NotModal);
  1508.  
  1509.                                                                     { C u r s o r   T a b l e   &   Z o n e s:    -    -    -    }
  1510.         NewCursorTable(2, arrowCursor);                                {Create Cursor Table number 2.  The standard    }
  1511.                                                                     {    Arrow cursor is the default for this table.    }
  1512.         CursorZone(2, PrinterIcon, arrowCursor, 20, 32, 52, 64);        {Add two Cursor Zones to the Cursor Table.        }
  1513.         CursorZone(2, ModemIcon, arrowCursor, 65, 32, 97, 64);        {    The user can click these zones, thereby    }
  1514.                                                                     {    making the Printer and Modem icons click    }
  1515.                                                                     {    sensitive.                                    }
  1516.         UseCursorTable(2);                                                {The current window will use Cursor Table no 2.    }
  1517.                                                                     {    Note that a cursor table exists                }
  1518.                                                                     {    independently of windows.  In fact, several    }
  1519.                                                                     {    windows can each use the same cursor        }
  1520.                                                                     {    table.  It is not necessary to create a cursor    }
  1521.                                                                     {    table each time you want a window to use it.    }
  1522.                                                                     {    You just use the UseCursorTable routine to    }
  1523.                                                                     {    make a window use a cursor table.            }
  1524.  
  1525.                                                                     {Create 3 radio buttons used to select the MIDI    }
  1526.                                                                     {    interface's speed…                            }
  1527.         NewButton(MidiHalfMeg, 142, 27, 216, 39, '  .5 MHz.', radioButProc, enabled, notSelected);        {                }
  1528.         NewButton(MidiOneMeg, 142, 43, 216, 55, '1.0 MHz.', radioButProc, enabled, notSelected);        {                }
  1529.         NewButton(MidiTwoMeg, 142, 58, 216, 72, '2.0 MHz.', radioButProc, enabled, notSelected);        {                }
  1530.         SelectButton(MidiSpeed, selected);                            {Set the current speed button                    }
  1531.  
  1532.         DrawWindow3Contents;                                        {Draw the rest of the objects in this demo        }
  1533.                                                                     {    window.  All Tools Plus objects are auto-    }
  1534.                                                                     {    matically updated when a window needs to    }
  1535.                                                                     {    be refreshed, such as when you bring it to    }
  1536.                                                                     {    the front to make it active.                    }
  1537.                                                                     {        Non-Tools Plus objects (ie: those you    }
  1538.                                                                     {    create) have to be redrawn separately in    }
  1539.                                                                     {    response to a doRefresh event, so it's a    }
  1540.                                                                     {    good idea to keep them in a separate        }
  1541.                                                                     {    routine.                                        }
  1542.  
  1543.         EnableMenu(FileMenu, CloseItem, enabled);                    {Enable the File menu's Close command, now    }
  1544.     end;                                                                {    that there's a window to close.                }
  1545.  
  1546.  
  1547.  
  1548. { C r e a t e   D e m o   W i n d o w   4 :    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    }
  1549. {    This demo shows off several Tools Plus features:                                                                }
  1550. {        • Cursor animation (the wristwatch cursor spins)                                                                }
  1551. {        • Filtering unwanted events when the application is busy (all typing and mouse clicks are filtered, so your    }
  1552. {            application only gets Command-. events when the user wants to halt a lengthy process).                }
  1553. {        • Secondary event loop in an application                                                                    }
  1554. {        • Background processing (an ongoing process that runs all the time)                                            }
  1555. {        • Progress thermometer                                                                                        }
  1556.     procedure OpenDemoWindow4;
  1557.         var
  1558.             ThermometerRect: rect;                                        {Pregress thermometer's location                }
  1559.             PercentComplete: real;                                        {Percentage complete (.5 = 50%)                }
  1560.             NextThermometerTime: longint;                                {Next time when thermometer is updated (ticks)    }
  1561.             Done: boolean;                                                {Is this demo done? (either Command-. by user    }
  1562.                                                                     {    or thermometer is at 100%)                    }
  1563.     begin
  1564.         CursorShape(watchCursor);                                    {Set the cursor to a wrist-watch                    }
  1565.                                                                     {Open a window to tell the user about the        }
  1566.                                                                     {    lengthy process (automatically centered)…    }
  1567.         WindowOpen(DemoWindow4, 0, 0, 265, 100, '', dBoxProc + wCenter, NoGoAway, Modal);    {                    }
  1568.         TextFont(systemFont);                                            {The message is displayed in Chicago 12pt.        }
  1569.         TextSize(12);                                                    {                                                }
  1570.         DrawWindow4Contents;                                        {Draw this window's message                    }
  1571.         SetRect(ThermometerRect, 15, 42, 250, 55);                    {Define the thermometer's co-ordinates            }
  1572.         PercentComplete := 0;                                            {Initialize the thermometer's value (0% done)    }
  1573.         NextThermometerTime := 0;                                        {Force thermometer to be updated right away    }
  1574.         Done := false;                                                    {This demo is not completed yet                    }
  1575.  
  1576.                                                                     { L o c a l   E v e n t   L o o p                        }
  1577.         while not Done do                                            {Keep running until we're done…                }
  1578.             if PollSystem(Poll) then                                        {If an event has been detected…                }
  1579.                 case Poll.What of                                            {Determine what kind of event has occurred…    }
  1580.                     doRefresh:                                                 {A window needs to be refreshed…                }
  1581.                         RefreshWindow;                                        {    redraw the specified window.  A screen        }
  1582.                                                                     {    saver may cause this event, even in a        }
  1583.                                                                     {    modal window like this one.                    }
  1584.                     doKeyDown:                                                {If the user typed a character.  All characters    }
  1585.                         Done := true;                                            {    other than Command-. are filtered out, so    }
  1586.                                                                     {    we know the user has typed Command-. to    }
  1587.                                                                     {    halt the process.                            }
  1588.                     otherwise                                                {All other events are ignored                    }
  1589.                 end                                                        {                                                }
  1590.                                                                     { B a c k g r o u n d   p r o c e s s i n g …            }
  1591.             else if TickCount >= NextThermometerTime then            {No event available, so if it is time to do the next    }
  1592.                 begin                                                        {    thermometer update…                        }
  1593.                     NextThermometerTime := TickCount + 10;                    {Next update will be in 10 ticks (6 times/second)    }
  1594.                     PercentComplete := PercentComplete + 0.005;            {Add 1/2% completion to the thermometer        }
  1595.                     DrawThermometer(ThermometerRect, PercentComplete);    {Update the progress thermometer                }
  1596.                     if PercentComplete >= 1 then                            {If the thermometer reads 100%…                }
  1597.                         Done := true;                                            {    we're done with this demo window.            }
  1598.                 end;                                                        {                                                }
  1599.  
  1600.         CloseTheWindow(DemoWindow4);                                {End this demo by closing its window            }
  1601.         ResetCursor;                                                    {Get rid of the watch cursor, and set it according}
  1602.     end;                                                                {    to its location and relation to active window.    }
  1603.  
  1604.  
  1605.  
  1606. { C r e a t e   D e m o   W i n d o w   5 :    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    }
  1607. {    This demo shows how to write code that does color drawing that is dependent on the monitor's settings (ie: the    }
  1608. {    number of colors, number of shades of gray, or black and white).  With very little additional effort, your            }
  1609. {    application can also be made to be compatible with Macintoshes that have multiple-monitors.                    }
  1610.     procedure OpenDemoWindow5;
  1611.     begin                                                            {Open the window (it automatically shifts down    }
  1612.                                                                     {    to compensate for an open Tool Bar, and its    }
  1613.                                                                     {    position is 'tiled')…                            }
  1614.         WindowOpen(DemoWindow5, 0, 0, 310, 208, 'Color Drawing and Multiple Monitors', noGrowDocProc + wTile, GoAway, NotModal);
  1615.                                                                     {Create the 'OK' push-button.  This is the        }
  1616.                                                                     {    window's default button, and it is selected    }
  1617.                                                                     {    automatically when you press Return or        }
  1618.         NewButton(OkButton, 125, 170, 185, 190, 'OK', DefaultButton, enabled, notSelected);                {    Enter.    }
  1619.  
  1620.  
  1621.         TextFont(Geneva);                                                {All text is drawn in Geneva 9pt.                    }
  1622.         TextSize(9);                                                    {                                                }
  1623.         DrawWindow5Contents;                                        {Draw the rest of the objects in this demo        }
  1624.                                                                     {    window.  All Tools Plus objects are auto-    }
  1625.                                                                     {    matically updated when a window needs to    }
  1626.                                                                     {    be refreshed, such as when you bring it to    }
  1627.                                                                     {    the front to make it active.                    }
  1628.                                                                     {        Non-Tools Plus objects (ie: those you    }
  1629.                                                                     {    create) have to be redrawn separately in    }
  1630.                                                                     {    response to a doRefresh event, so it's a    }
  1631.                                                                     {    good idea to keep them in a separate        }
  1632.                                                                     {    routine.                                        }
  1633.  
  1634.         EnableMenu(FileMenu, CloseItem, enabled);                    {Enable the File menu's Close command, now    }
  1635.     end;                                                                {    that there's a window to close.                }
  1636.  
  1637.  
  1638.  
  1639. { C r e a t e   D e m o   W i n d o w   6 :    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    }
  1640. {    This demo shows off Tools Plus's Dynamic Alerts.  Dynamic Alerts are self contained (you don't have to do        }
  1641. {    anything other than call it and wait for the user to respond).  Breaking from tradition that was previously            }
  1642. {    established by the 'OpenDemoWindow…' routines, this demo does everything pertaining to displaying            }
  1643. {    Dynamic Alerts, detecting user action, and responding to events.                                                }
  1644.     procedure OpenDemoWindow6;
  1645.         const
  1646.             ContinueAlert = 11500;                                        {Button definition for a "Continue" dynamic alert    }
  1647.             SilentContinueAlert = -11500;                                    {Button definition for a "Continue" dynamic alert    }
  1648.                                                                     {    that doesn't beep the user.                    }
  1649.             EndAlert = -33987;                                            {Button definition using three custom buttons    }
  1650.         var
  1651.             AltButton: integer;                                            {Alert button clicked by the user                }
  1652.     begin
  1653.                                                                     {These first 2 alerts ignore which button that    }
  1654.                                                                     {    was clicked…                                }
  1655.         AltButton := AlertBox(noteIcon, concat('This is an dynamic alert box.  Dynamic Alerts automatically adjust to accommodate the text your application provides them.  In fact, they’re smart enough to recognize “carriage returns” as “new line” commands.', ReturnKey, ReturnKey, 'Click “Continue” for more examples.'), ContinueAlert);
  1656.         AltButton := AlertBox(stopIcon, concat('Icons…', ReturnKey, ReturnKey, 'You can display any icon you want in a Dynamic alert, including color icons.', ReturnKey, ReturnKey, 'AlertBox calls Tools Plus’s DrawIcon routine, so it’s smart enough to pick the right icon for your monitor’s settings.'), SilentContinueAlert);
  1657.                                                                     {This alert displays 2 buttons: Yes and No.  If    }
  1658.                                                                     {    the user answers Yes, the demo continues…}
  1659.         if YesAltBut = AlertBox(noteIcon, 'Do you want to continue with more examples of Dynamic Alerts?', YesNoAlert) then
  1660.             begin                                                        {                                                }
  1661.                 AltButton := AlertBox(cautionIcon, 'Dynamic Alerts can even do unusual things, like alerts with no buttons (click in this window to get rid of it).', NoButtonAlert);
  1662.                 AltButton := AlertBox(ModemIcon, concat('Save modem preferences before quitting?', ReturnKey, '(Just kidding!)'), NoYesCanAlert);
  1663.                 AlertButtonName(7, 'Yup!');                                    {This Dynamic Alert shows how you can rename    }
  1664.                 AlertButtonName(8, 'Wow!');                                {    buttons to customize your application.  The    }
  1665.                 AlertButtonName(9, 'Gnarly');                                {    available options make it seem like you have}
  1666.                 AltButton := AlertBox(NoIcon, 'So, are you impressed with Dynamic Alerts?', EndAlert);    {    thousands of    }
  1667.             end                                                            {    customized alerts in your application.        }
  1668.     end;                                                                {                                                }
  1669.  
  1670.  
  1671. { C r e a t e   D e m o   W i n d o w   7 :    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    }
  1672. {    This demo demonstrates how easy it is to create and work with Pop-Up Menus.  Tools Plus gives you features    }
  1673. {    and options ordinary Pop-Up Menus don’t have.  Also, Tools Plus's Pop-Up menu's work identically across all    }
  1674. {    systems, unlike ordinary Mac Pop-Up Menus that provide some features that are exclusive to System 7.        }
  1675.     procedure OpenDemoWindow7;
  1676.     begin
  1677.                                                                     {Open the window (it automatically shifts down    }
  1678.                                                                     {    to compensate for an open Tool Bar, and its    }
  1679.                                                                     {    position is 'tiled')…                            }
  1680.         WindowOpen(DemoWindow7, 0, 0, 390, 296, 'Pop-Up Menus', noGrowDocProc + wTile, GoAway, NotModal);    {    }
  1681.  
  1682.                                                                     { P o p - U p   M e n u s :    -    -    -    -    -    -    }
  1683.     {    Example 1…                                                {Create a standard (default) Pop-Up Menu.  It is    }
  1684.                                                                     {    displayed in the System Font (Chicago 12pt)}
  1685.                                                                     {    and only allows selection of one item at a    }
  1686.                                                                     {    time.                                        }
  1687.                                                                     {    NOTE:  If you specify the bottom of the Pop-    }
  1688.                                                                     {    Up Menu's rectangle to be the same as the    }
  1689.                                                                     {    top, it is be created at exactly the font's        }
  1690.         NewPopUp(popMenu1, 110, 20, 209, 20, 'Day of Week:', popupDefaultType, enabled);    {    height.                }
  1691.         PopUpMenu(popMenu1, 1, enabled, 'Sunday');                    {Populate the Pop-Up Menu with days of the        }
  1692.         PopUpMenu(popMenu1, 2, enabled, 'Monday');                    {    week.  At this point, no item is selected yet.    }
  1693.         PopUpMenu(popMenu1, 3, enabled, 'Tuesday!•');                {        Notice that the third item (Tuesday) is    }
  1694.         PopUpMenu(popMenu1, 4, enabled, 'Wednesday');                {    marked with a bullet character (•).  Marking    }
  1695.         PopUpMenu(popMenu1, 5, enabled, 'Thursday');                {    any item 'selects' it, and automatically        }
  1696.         PopUpMenu(popMenu1, 6, enabled, 'Friday');                    {    displays it in the menu's content area.        }
  1697.         PopUpMenu(popMenu1, 7, enabled, 'Saturday');                {                                                }
  1698.  
  1699.  
  1700.     {    Example 2…                                                {Create a second Pop-Up Menu.  This one        }
  1701.                                                                     {    shows the selected item's icon, and hides    }
  1702.                                                                     {    the 'down arrow'.                            }
  1703.         NewPopUp(popMenu2, 110, 70, 216, 70, 'Search Here:', popupIconTitle + popupNoArrow, enabled);    {            }
  1704.         PopUpMenu(popMenu2, 1, enabled, 'Desktop^44');                {Populate the Pop-Up menu with a simulated    }
  1705.         PopUpMenu(popMenu2, 2, enabled, 'Hard Disk^45');            {    path starting from the Desktop to folders.    }
  1706.         PopUpMenu(popMenu2, 3, enabled, 'Tools Plus^46');            {        Each menu item has an associated icon    }
  1707.         PopUpMenu(popMenu2, 4, enabled, 'THINK C^47');                {    (its specifier follows the '^' symbol.)  Note    }
  1708.         PopUpMenu(popMenu2, 5, enabled, 'Libraries^47');                {    that the Menu Manager automatically adds    }
  1709.         PopUpMenu(popMenu2, 6, enabled, '#Includes^47');            {    256 to the specifier to calculate the icon's    }
  1710.                                                                     {    ID.  Example:  ^44 + 256 = 300 'cicn' ID        }
  1711.         CheckPopUp(popMenu2, 1, on);                                {Select the first item by placing a check mark    }
  1712.                                                                     {    beside it.                                    }
  1713.  
  1714.  
  1715.     {    Example 3…                                                {Create a third Pop-Up Menu that shows off how    }
  1716.                                                                     {    easily you can create picture menus.  This    }
  1717.                                                                     {    one uses two icons and no text.                }
  1718.         NewPopUp(popMenu3, 110, 120, 170, 154, 'Serial Port:', popupIconTitle + popupNoArrow, enabled);        {        }
  1719.         PopUpMenu(popMenu3, 1, enabled, '^48');                        {Populate the Pop-Up menu with the Printer and    }
  1720.         PopUpMenu(popMenu3, 2, enabled, '^49');                        {    Modem icons.                                }
  1721.         CheckPopUp(popMenu3, 1, on);                                {Select the first item by placing a check mark    }
  1722.                                                                     {    beside it.                                    }
  1723.  
  1724.  
  1725.     {    Example 4…                                                {Create a fourth Pop-Up Menu that is a special    }
  1726.                                                                     {    type of control.  This one has a fixed title,    }
  1727.                                                                     {    and is used like an on-window pull-down        }
  1728.                                                                     {    menu.                                        }
  1729.         NewPopUp(popMenu4, 110, 190, 216, 190, 'Format', popupFixedTitle, enabled);        {                            }
  1730.         PopUpMenu(popMenu4, 1, enabled, 'Clear');                    {Populate the menu with the selections that can    }
  1731.         PopUpMenu(popMenu4, 2, enabled, 'Paragraph…');                {    be made.  Even though you can put check    }
  1732.         PopUpMenu(popMenu4, 3, enabled, 'Character…');                {    marks or other symbols beside these items,    }
  1733.         PopUpMenu(popMenu4, 4, enabled, 'Style…');                    {    this demo makes them perform an action    }
  1734.                                                                     {    just like pull-down menus.                    }
  1735.  
  1736.  
  1737.     {    Example 5…                                                {Mini Pop-Up Menu…                            }
  1738.         TextFont(Geneva);                                                {Set the window's font to Geneva 9pt.  The pop-    }
  1739.         TextSize(9);                                                    {    up menu will use these settings.            }
  1740.                                                                     {Create the last menu using a different (non-    }
  1741.                                                                     {    System) font.  This feature is available on    }
  1742.                                                                     {    all systems (unlike ordinary pop-up menus).    }
  1743.                                                                     {    Never dim the menu's title or the selected    }
  1744.                                                                     {    item because Geneva 9pt is unreadable        }
  1745.                                                                     {    when its dithered on a 1-bit monitor (black    }
  1746.                                                                     {    and white) monitor…                        }
  1747.         NewPopUp(popMenu5, 110, 240, 143, 240, 'Size:', popupUseWFont + popupNoArrow + popupNeverDimTitle + popupNeverDimSelection, enabled);
  1748.         PopUpMenu(popMenu5, 1, enabled, '9');                        {Populate the menu with a fictitious set of        }
  1749.         PopUpMenu(popMenu5, 2, enabled, '10');                        {    available font sizes.  Once the menu is        }
  1750.         PopUpMenu(popMenu5, 3, enabled, '12!•');                        {    created, you can change the window's        }
  1751.         PopUpMenu(popMenu5, 4, enabled, '14');                        {    font and size without affecting the pop-up    }
  1752.         PopUpMenu(popMenu5, 5, enabled, '18');                        {    menus.                                        }
  1753.         PopUpMenu(popMenu5, 6, enabled, '24');                        {        The third item (12pt) is marked with a    }
  1754.         PopUpMenu(popMenu5, 7, enabled, '36');                        {    bullet (•) to select that item.                    }
  1755.  
  1756.         DrawWindow7Contents;                                        {Draw the rest of the objects in this demo        }
  1757.                                                                     {    window.  All Tools Plus objects are auto-    }
  1758.                                                                     {    matically updated when a window needs to    }
  1759.                                                                     {    be refreshed, such as when you bring it to    }
  1760.                                                                     {    the front to make it active.                    }
  1761.                                                                     {        Non-Tools Plus objects (ie: those you    }
  1762.                                                                     {    create) have to be redrawn separately in    }
  1763.                                                                     {    response to a doRefresh event, so it's a    }
  1764.                                                                     {    good idea to keep them in a separate        }
  1765.                                                                     {    routine.                                        }
  1766.  
  1767.         EnableMenu(FileMenu, CloseItem, enabled);                    {Enable the File menu's Close command, now    }
  1768.     end;                                                                {    that there's a window to close.                }
  1769.  
  1770.  
  1771.  
  1772. { C r e a t e   D e m o   W i n d o w   8 :    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    }
  1773. {    This demo shows off Tools Plus's Picture Buttons.  A variety of buttons have been created to give you a taste    }
  1774. {    of their abilities.  The top of this window includes a "window tool bar", a tool bar that is associated with a specific    }
  1775. {    window, such as the kind seen in popular word processors.                                                        }
  1776. {      Picture Buttons are more versatile than most custom controls because you design their appearance and their    }
  1777. {    behavior.  It's almost like having a button-building kit at your disposal.                                            }
  1778.     procedure OpenDemoWindow8;
  1779.         const                                                            {Define constants for the various bahavior and    }
  1780.                                                                     {    appearance specifications…                }
  1781.                                                                     {Big 3D toolbar buttons stay down when            }
  1782.                                                                     {    selected, lightened when selected, and        }
  1783.                                                                     {    get whited out when disabled…                }
  1784.             BigToolBarSpec = picbutLockSelected + picbutBigSICN3D + picbutSelectLightenSICN3D + picbutDimUsingWhite;
  1785.                                                                     {Small 3D toolbar buttons pop back up after        }
  1786.                                                                     {    being selected, lightened when selected,    }
  1787.                                                                     {    and get whited out when disabled…            }
  1788.             SmallToolBarSpec = picbutSelectLightenSICN3D + picbutDimUsingWhite;    {                                    }
  1789.                                                                     {The Plus/Minus button pair produce repeated    }
  1790.                                                                     {    doPictButton events while they are held        }
  1791.                                                                     {    down, have an alternate image when        }
  1792.                                                                     {    selected, and don't look different when        }
  1793.                                                                     {    disabled…                                    }
  1794.             PlusMinusSpec = picbutRepeatEvents + picbutSelectAltImage + picbutDimNoChange;    {                    }
  1795.                                                                     {The ordinary icons (printer and modem) are        }
  1796.                                                                     {    selected when the mouse-down occurs,        }
  1797.                                                                     {    stay down when selected, darken when        }
  1798.                                                                     {    selected.  When disabled, use a white        }
  1799.                                                                     {    screen effect and preserve the border…    }
  1800.             OrdinaryIconSpec = picbutInstantEvent + picbutLockSelected + picbutSelectDarken + picbutDimUsingWhite + picbutDimLeaveBorder;
  1801.                                                                     {These tapedeck control buttons are selected    }
  1802.                                                                     {    when the mouse-down occurs, stay down    }
  1803.                                                                     {    when selected and use an alternate icon.    }
  1804.                                                                     {    They look the same disabled…                }
  1805.             TapedeckLockSpec = picbutInstantEvent + picbutLockSelected + picbutSelectAltImage + picbutDimNoChange;
  1806.                                                                     {These tape deck controls to not lock down, and}
  1807.             TapedeckSpec = picbutSelectAltImage + picbutDimNoChange;{    they look the same disabled.                }
  1808.     begin
  1809.                                                                     {Open the window (it automatically shifts down    }
  1810.                                                                     {    to compensate for an open Tool Bar, and its    }
  1811.                                                                     {    position is 'tiled')…                            }
  1812.         WindowOpen(DemoWindow8, 0, 0, 472, 315, 'Picture Buttons', noGrowDocProc + wTile, GoAway, NotModal);{    }
  1813.         ToolBarValue := 100;                                            {Initialize the tool bar's value                    }
  1814.  
  1815.         DrawWindow8Contents;                                        {Draw all the objects in this demo window except}
  1816.                                                                     {    for the buttons.  This is done first to create    }
  1817.                                                                     {    a toolbar on which some buttons can be        }
  1818.                                                                     {    placed.  All Tools Plus objects are auto-        }
  1819.                                                                     {    matically updated when a window needs to    }
  1820.                                                                     {    be refreshed, such as when you bring it to    }
  1821.                                                                     {    the front to make it active.                    }
  1822.                                                                     {        Non-Tools Plus objects (ie: those you    }
  1823.                                                                     {    create) have to be redrawn separately in    }
  1824.                                                                     {    response to a doRefresh event, so it's a    }
  1825.                                                                     {    good idea to keep them in a separate        }
  1826.                                                                     {    routine.                                        }
  1827.  
  1828.                                                                     {Create a pop-up menu in the title bar menu        }
  1829.                                                                     {    using the window's font (Geneva 9).…        }
  1830.         if HasColorQuickDraw then                                    {If Color Quickdraw is available…                }
  1831.             RGBForeColor(ToolBarGray);                                    {    set foreground color to match the toolbar.    }
  1832.                                                                     {    The Pop-Up Menu picks this up to remember}
  1833.                                                                     {    which color is behind the Pop-Up Menu.        }
  1834.         NewPopUp(popMenu1, 9, 7, 68, 7, '', popupUseWFont + popupNoArrow + popupNeverDimOutline + popupNeverDimSelection, enabled);
  1835.         PenColorNormal;                                                {Restore to default colors                        }
  1836.         PopUpMenu(popMenu1, 1, enabled, 'Normal!√');                {Populate the pop-up menu with some items.    }
  1837.         PopUpMenu(popMenu1, 2, disabled, '-');                        {    Demo 7 gives you details about how pop-up    }
  1838.         PopUpMenu(popMenu1, 3, enabled, 'Promote');                    {    menus are created.                            }
  1839.         PopUpMenu(popMenu1, 4, enabled, 'Demote');                    {                                                }
  1840.         PopUpMenu(popMenu1, 5, enabled, 'Lateral');                    {                                                }
  1841.  
  1842.                                                                     {Create a pop-up menu to control the 'globe'        }
  1843.                                                                     {    button's 'acceleration curve'…                }
  1844.         NewPopUp(ButtonSpeedMenu, 406, 219, 460, 219, 'ΔRate:', popupUseWFont + popupNoArrow, enabled);    {    }
  1845.         PopUpMenu(ButtonSpeedMenu, 1, enabled, 'Linear');            {Populate the pop-up menu with the choices…    }
  1846.         PopUpMenu(ButtonSpeedMenu, 2, enabled, 'Slow');            {                                                }
  1847.         PopUpMenu(ButtonSpeedMenu, 3, enabled, 'Medium!√');        {                                                }
  1848.         PopUpMenu(ButtonSpeedMenu, 4, enabled, 'Fast');                {                                                }
  1849.  
  1850.  
  1851.  
  1852.                                                                     {C r e a t e   a l l   p i c t u r e   b u t t o n s …        }
  1853.         NewPictButton(LeftArrowButton, 103, 3, LeftArrowIcon, picbutSelectAltImage + picbutDimNoChange, enabled, notSelected, 0, 0, 0);
  1854.         NewPictButton(RightArrowButton, 126, 3, RightArrowIcon, picbutSelectAltImage + picbutDimNoChange, enabled, notSelected, 0, 0, 0);
  1855.  
  1856.         NewPictButton(LeftAlignButton, 172, 3, LeftAlignIcon, BigToolBarSpec, enabled, notSelected, 0, 0, 0);        {    }
  1857.         NewPictButton(CenterAlignButton, 195, 3, CenterAlignIcon, BigToolBarSpec, enabled, notSelected, 0, 0, 0);{    }
  1858.         NewPictButton(RightAlignButton, 218, 3, RightAlignIcon, BigToolBarSpec, enabled, notSelected, 0, 0, 0);    {    }
  1859.         NewPictButton(JustifyButton, 241, 3, JustifyIcon, BigToolBarSpec, enabled, notSelected, 0, 0, 0);            {    }
  1860.  
  1861.         NewPictButton(CutButton, 288, 4, CutIcon, SmallToolBarSpec, enabled, notSelected, 0, 0, 0);                {    }
  1862.         NewPictButton(BucketButton, 311, 4, BucketIcon, SmallToolBarSpec, enabled, notSelected, 0, 0, 0);        {    }
  1863.         NewPictButton(ClipboardButton, 334, 4, ClipboardIcon, SmallToolBarSpec, enabled, notSelected, 0, 0, 0);    {    }
  1864.  
  1865.         NewPictButton(PlusButton, 441, 5, PlusIcon, PlusMinusSpec, enabled, notSelected, 0, 0, 0);                {    }
  1866.         NewPictButton(MinusButton, 441, 15, MinusIcon, PlusMinusSpec, enabled, notSelected, 0, 0, 0);            {    }
  1867.         SetPictButtonSpeed(PlusButton, 2);                            {Set the button speed to 2 steps per second for    }
  1868.         SetPictButtonSpeed(MinusButton, 2);                            {    these two buttons.                            }
  1869.  
  1870.         NewPictButton(PrinterButton, 28, 153, PrinterIcon, OrdinaryIconSpec, enabled, selected, 0, 0, 0);            {    }
  1871.         NewPictButton(ModemButton, 69, 153, ModemIcon, OrdinaryIconSpec, enabled, notSelected, 0, 0, 0);        {    }
  1872.  
  1873.     {This stepping button has nine icon images in its SICN resource.  The button's value changes automatically with    }
  1874.     {    the top 1/2 of the button incrementing the value and the bottom 1/2 decrementing it (one step each time the    }
  1875.     {    button is clicked).  This is a BID 3D button that looks 'pushed' when selected (not darker or ligher)…            }
  1876.         NewPictButton(SteppingButton, 147, 161, ScrollingIcon, picbutAutoValueChg + picbutTopBottomSplit + picbutBigSICN3D + picbutSelectPushedSICN3D, enabled, notSelected, 1, 3, 9);
  1877.  
  1878.     {This scrolling button has nine icon images in its SICN resource.  It keeps producing doPictButton events while    }
  1879.     {    the mouse is held down.  The button's value changes automatically with the top 1/2 of the button                }
  1880.     {    incrementing the value and the bottom 1/2 decrementing it.  This is a BID 3D button that looks 'pushed' when    }
  1881.     {    selected (not darker or ligher)…                                                                                }
  1882.         NewPictButton(ScrollingButton, 170, 161, ScrollingIcon, picbutRepeatEvents + picbutAutoValueChg + picbutTopBottomSplit + picbutBigSICN3D + picbutSelectPushedSICN3D, enabled, notSelected, 1, 5, 9);
  1883.  
  1884.     {This is just about the most complicated button you can create.  It keeps producing doPictButton events while    }
  1885.     {    the mouse is held down.  The button's value changes automatically with the right 1/2 of the button            }
  1886.     {    incrementing the value and the left decrementing it.  The rate of change accelerates (at a medium rate) over    }
  1887.     {    time, and the button's values "wrap" (maximum + 1 = start at minimum).  An alternate icon is used when the    }
  1888.     {    button is selected.  A white screen is applied to this icon when the button is disabled.                        }
  1889.         NewPictButton(GlobeButton, 410, 153, GlobeIcon, picbutRepeatEvents + picbutAutoValueChg + picbutScaleMedAccel + picbutValueWrap + picbutLeftRightSplit + picbutSelectAltImage + picbutDimUsingWhite, enabled, notSelected, -179, 0, 180);
  1890.  
  1891.                                                                     {Tapedeck buttons always have 1 selected…    }
  1892.         NewPictButton(RewindButton, 17, 235, RewindIcon, TapedeckLockSpec, enabled, notSelected, 0, 0, 0);    {    }
  1893.         NewPictButton(StopButton, 48, 235, StopTapeIcon, TapedeckSpec, enabled, notSelected, 0, 0, 0);            {    }
  1894.         NewPictButton(FastFwdButton, 79, 235, FastFwdIcon, TapedeckLockSpec, enabled, notSelected, 0, 0, 0);    {    }
  1895.         NewPictButton(PauseButton, 17, 255, PauseIcon, TapedeckSpec, enabled, notSelected, 0, 0, 0);            {    }
  1896.         NewPictButton(RecordButton, 48, 255, RecordIcon, TapedeckSpec, enabled, notSelected, 0, 0, 0);            {    }
  1897.         NewPictButton(PlayButton, 79, 255, PlayIcon, TapedeckLockSpec, enabled, notSelected, 0, 0, 0);            {    }
  1898.  
  1899.     {This is a dual state button (Power-On, Power-Off), so it is considered to be a "Multi-Stage" button (Off=0, 1=On).}
  1900.     {    The button's value changes automatically when selected by the user.  The values 'wrap' to allow 1 (on) to    }
  1901.     {    start back at 0 (off) again.  An alternate icon is used to depict the selected button (down position), and        }
  1902.     {    disabled button for maximum visual control…                                                                }
  1903.         NewPictButton(PowerButton, 173, 235, PowerIcon, picbutMultiStage + picbutAutoValueChg + picbutValueWrap + picbutSelectAltImage + picbutDimAltImage, enabled, notSelected, 0, 0, 1);
  1904.  
  1905.     {This is a dual state button that uses a set of PICTs. Like the button above, it is Multi-State (left=0, right=1) and    }
  1906.     {    its value changes automatically when selected by the user.  This button uses different PICTs for the            }
  1907.     {    selected state, and for the screen depth (8-bit, 4-bit, and B&W).  It also uses a mask, even though it is not    }
  1908.     {    necessary on a white background.                                                                            }
  1909.         NewPictButton(FlipButton, 163, 277, FlipSwitchPICT, picbutAutoValueChg + picbutLeftRightSplit + picbutMultiStage + picbutUsePICTS + picbutGray4use8 + picbutSelectAltImage + picbutDimNoChange, enabled, notSelected, 0, 0, 1);
  1910.                                                                     {This is a really simple push-button that uses an    }
  1911.                                                                     {    alternate icon when the button is selected.    }
  1912.                                                                     {    When disabled, a white screen is overlayed    }
  1913.                                                                     {    and the border is preserved.                }
  1914.         NewPictButton(DoneButton, 392, 280, DoneIcon, picbutSelectAltImage + picbutDimUsingWhite + picbutDimLeaveBorder, enabled, notSelected, 0, 0, 0);
  1915.  
  1916.         EnableMenu(FileMenu, CloseItem, enabled);                    {Enable the File menu's Close command, now    }
  1917.     end;                                                                {    that there's a window to close.                }
  1918.  
  1919.  
  1920. { C r e a t e   D e m o   W i n d o w   9 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1921. {    In Tools Plus, creating a Tool Bar is as easy as opening a window.  Tools Plus makes sure the Tools Bar is        }
  1922. {    always at the front, and always active.  This Tool Bar contains a Pop-Up Menu and several Picture Buttons (they    }
  1923. {    are simply a duplicate of the 'window tool bar' seen in demo 8.                                                    }
  1924. {      Tools Plus automatically hides the Tool Bar when your application is suspended, and displays it again when    }
  1925. {    your application resumes (when running under MultiFinder™ or System 7).                                        }
  1926. {      This routine is used to both open and close the application's Tool Bar.  Note that all open windows can            }
  1927. {    optionally be shifted down when a Tool Bar is opened to make sure that no windows are hidden behind the Tool    }
  1928. {    Bar.  You can also tell Tools Plus to offset future windows downward to account for the Tool Bar's space on the    }
  1929. {    monitor.                                                                                                        }
  1930.     procedure OpenDemoWindow9;
  1931.         const                                                            {These constants describe the behavior and    }
  1932.                                                                     {    look of picture buttons in the Tool Bar.        }
  1933.                                                                     {    Demo 8 provides more detail about picture    }
  1934.                                                                     {    buttons. All the buttons here have been        }
  1935.                                                                     {    duplicated from Demo 8…                    }
  1936.             BigToolBarSpec = picbutLockSelected + picbutBigSICN3D + picbutSelectLightenSICN3D + picbutDimUsingWhite;
  1937.             SmallToolBarSpec = picbutSelectLightenSICN3D + picbutDimUsingWhite;    {                                    }
  1938.     begin
  1939.                                                                     { O p e n   T o o l   B a r …                        }
  1940.         if not WindowIsOpen(ToolBarWindow) then                    {If the Tool Bar is not open…                    }
  1941.             begin                                                        {                                                }
  1942.                 ToolBarOpen(ToolBarWindow, 26, tbShiftWindows + tbOffsetNewWindows);        {Open a Tool Bar that is 26    }
  1943.                                                                     {    pixels high.  Shift all open windows down as    }
  1944.                                                                     {    the Tool Bar opens, and as future windows    }
  1945.                                                                     {    are opened, offset them downward to        }
  1946.                                                                     {    compensate for the open Tool Bar.            }
  1947.  
  1948.                 RenameItem(DemosMenu, 10, 'Hide Tool Bar');                {Rename the menu item                            }
  1949.  
  1950.                 DrawWindow9Contents;                                    {Paint the Tool Bar gray.  Picture buttons will be    }
  1951.                                                                     {    placed on top of the gray.  All Tools Plus    }
  1952.                                                                     {    objects are automatically updated when a    }
  1953.                                                                     {    window needs to be refreshed.                }
  1954.                                                                     {        Non-Tools Plus objects (ie: those you    }
  1955.                                                                     {    create) have to be redrawn separately in    }
  1956.                                                                     {    response to a doRefresh event, so it's a    }
  1957.                                                                     {    good idea to keep them in a separate        }
  1958.                                                                     {    routine.                                        }
  1959.                 if HasColorQuickDraw then                                {If Color Quickdraw is available…                }
  1960.                     RGBForeColor(ToolBarGray);                                {    set foreground color to match the toolbar.    }
  1961.                                                                     {    The Pop-Up Menu picks this up to remember}
  1962.                                                                     {    which color is behind the Pop-Up Menu.        }
  1963.                 TextFont(Geneva);                                            {The pop-up menu will use Geneva 9pt            }
  1964.                 TextSize(9);                                                {                                                }
  1965.                                                                     {Create the pop-up menu…                        }
  1966.                 NewPopUp(popMenu1, 9, 7, 68, 7, '', popupUseWFont + popupNoArrow + popupNeverDimOutline + popupNeverDimSelection, enabled);
  1967.                 PenColorNormal;                                            {Restore to default colors                        }
  1968.                 PopUpMenu(popMenu1, 1, enabled, 'Normal!√');            {Populate the pop-up menu with some items.    }
  1969.                 PopUpMenu(popMenu1, 2, enabled, 'Section');                {    Demo 7 gives you details about how pop-up    }
  1970.                 PopUpMenu(popMenu1, 3, enabled, 'Bullet');                {    menus are created.                            }
  1971.                 PopUpMenu(popMenu1, 4, enabled, 'Table');                {                                                }
  1972.  
  1973.                                                                     {C r e a t e   a l l   p i c t u r e   b u t t o n s …        }
  1974.                                                                     {    These are the same picture buttons you saw}
  1975.                                                                     {    described in detail in Demo 8…                }
  1976.                 NewPictButton(LeftArrowButton, 103, 2, LeftArrowIcon, picbutSelectAltImage + picbutDimNoChange, enabled, notSelected, 0, 0, 0);
  1977.                 NewPictButton(RightArrowButton, 126, 2, RightArrowIcon, picbutSelectAltImage + picbutDimNoChange, enabled, notSelected, 0, 0, 0);
  1978.                 NewPictButton(LeftAlignButton, 172, 2, LeftAlignIcon, BigToolBarSpec, enabled, notSelected, 0, 0, 0);
  1979.                 NewPictButton(CenterAlignButton, 195, 2, CenterAlignIcon, BigToolBarSpec, enabled, notSelected, 0, 0, 0);
  1980.                 NewPictButton(RightAlignButton, 218, 2, RightAlignIcon, BigToolBarSpec, enabled, notSelected, 0, 0, 0);
  1981.                 NewPictButton(JustifyButton, 241, 2, JustifyIcon, BigToolBarSpec, enabled, notSelected, 0, 0, 0);
  1982.                 NewPictButton(CutButton, 288, 3, CutIcon, SmallToolBarSpec, enabled, notSelected, 0, 0, 0);
  1983.                 NewPictButton(BucketButton, 311, 3, BucketIcon, SmallToolBarSpec, enabled, notSelected, 0, 0, 0);
  1984.                 NewPictButton(ClipboardButton, 334, 3, ClipboardIcon, SmallToolBarSpec, enabled, notSelected, 0, 0, 0);
  1985.             end
  1986.  
  1987.  
  1988.         else                                                            { C l o s e   T o o l   B a r …                        }
  1989.             begin                                                        {                                                }
  1990.                 WindowClose(ToolBarWindow);                                {Close the Tool Bar's window (all open windows    }
  1991.                                                                     {    automatically move up.                        }
  1992.                 RenameItem(DemosMenu, 10, 'Show Tool Bar');                {Rename the menu item                            }
  1993.             end                                                            {                                                }
  1994.     end;                                                                {                                                }
  1995.  
  1996.  
  1997. { C r e a t e   D e m o   W i n d o w   10 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  1998. {    In Tools Plus, creating a floating palette (windoid) is as easy as opening a window.  Tools Plus makes sure the    }
  1999. {    palette if opened behind the Tool Bar (if there is one) and in front of standard windows (if there are any).  Palettes}
  2000. {    are always active.                                                                                                }
  2001. {      Tools Plus automatically hides palettes when your application is suspended, and displays them when your    }
  2002. {    application resumes (when running under MultiFinder™ or System 7).                                            }
  2003.     procedure OpenDemoWindow10;
  2004.         var
  2005.             theButton: integer;                                            {Button number counter                            }
  2006.             theIcon: integer;                                                {Icon number counter                            }
  2007.             thePoint: point;                                                {Top left corner for button                        }
  2008.  
  2009.         const                                                            {All picture buttons on this floating palette are    }
  2010.                                                                     {    small SICN 3D icons (colorized by Tools        }
  2011.                                                                     {    Plus).  They respond instantly when clicked.}
  2012.             SmallButtonSpec = picbutInstantEvent + picbutSelectDarkenSICN3D;    {                                    }
  2013.     begin
  2014.                                                                     { O p e n   V e r t i c a l   P a l e t t e …                }
  2015.                                                                     {Open the floating palette (it automatically        }
  2016.                                                                     {    shifts down to compensate for an open Tool    }
  2017.                                                                     {    Bar)…                                        }
  2018.         WindowOpen(VerticalPalette, 450, 40, 495, 229, '', paletteProc, GoAway, NotModal);    {                        }
  2019.  
  2020.                                                                     {C r e a t e   a l l   p i c t u r e   b u t t o n s …        }
  2021.                                                                     {    Use some basic math to create the picture    }
  2022.                                                                     {    buttons for this palette.  All the picture        }
  2023.                                                                     {    buttons are buttons are sequentially        }
  2024.                                                                     {    numbered, and so is their placement on this    }
  2025.                                                                     {    palette.                                        }
  2026.         theIcon := FirstVPaletteIcon;                                    {Start with using the first icon in this palette        }
  2027.         for theButton := VPaletteMinButton to VPaletteMaxButton do    {Cycle through all buttons in this palette…        }
  2028.             begin                                                        {                                                }
  2029.                 thePoint.h := ord(not odd(theButton)) * 23 - 1;                {Horizontally, odd numbered buttons are at 0    }
  2030.                                                                     {    and even numbered buttons are at 23 pixels.}
  2031.                 thePoint.v := ((theButton - 1) div 2) * 19 - 1;                    {Two buttons fit side-by side horizontally, so    }
  2032.                                                                     {    after each two buttons, shift down 19 pixels.}
  2033.                                                                     {Create the picture button…                    }
  2034.                 NewPictButton(theButton, thePoint.h, thePoint.v, theIcon, SmallButtonSpec, enabled, notSelected, 0, 0, 0);
  2035.                 theIcon := theIcon + 1;                                        {Increment the icon for the next picture button    }
  2036.             end                                                            {                                                }
  2037.     end;                                                                {                                                }
  2038.  
  2039.  
  2040. { C r e a t e   D e m o   W i n d o w   11 : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  2041. {    In Tools Plus, creating a floating palette (windoid) is as easy as opening a window.  Tools Plus makes sure the    }
  2042. {    palette if opened behind the Tool Bar (if there is one) and in front of standard windows (if there are any).  Palettes}
  2043. {    are always active.                                                                                                }
  2044. {      Tools Plus automatically hides palettes when your application is suspended, and displays them when your    }
  2045. {    application resumes (when running under MultiFinder™ or System 7).                                            }
  2046.     procedure OpenDemoWindow11;
  2047.         var
  2048.             theButton: integer;                                            {Button number counter                            }
  2049.             theIcon: integer;                                                {Icon number counter                            }
  2050.             thePoint: point;                                                {Top left corner for button                        }
  2051.             ButtonsPerRow: integer;                                        {Number of buttons per row on this palette        }
  2052.             ButtonInRow: integer;                                        {Button number in current row (1 to x)            }
  2053.  
  2054.         const                                                            {All picture buttons on this floating palette        }
  2055.                                                                     {    respond instantly when clicked.  The image    }
  2056.                                                                     {    darkens when selected, is dithered when    }
  2057.                                                                     {    disabled (with it border left unaffected)…    }
  2058.             SmallButtonSpec = picbutInstantEvent + picbutSelectDarken + picbutDimUsingWhite + picbutDimLeaveBorder;
  2059.     begin
  2060.                                                                     { O p e n   H o r i z o n t a l   P a l e t t e …            }
  2061.                                                                     {Open the floating palette (it automatically        }
  2062.                                                                     {    shifts down to compensate for an open Tool    }
  2063.                                                                     {    Bar)…                                        }
  2064.         WindowOpen(HorizontalPalette, 239, 260, 508, 299, '', altPaletteProc, GoAway, NotModal);    {                    }
  2065.  
  2066.                                                                     {C r e a t e   a l l   p i c t u r e   b u t t o n s …        }
  2067.                                                                     {    Use some basic math to create the picture    }
  2068.                                                                     {    buttons for this palette.  All the picture        }
  2069.                                                                     {    buttons are buttons are sequentially        }
  2070.                                                                     {    numbered, and so is their placement on this    }
  2071.                                                                     {    palette.  Double borders between groups of    }
  2072.                                                                     {    buttons are created by placing the buttons    }
  2073.                                                                     {    further apart.                                }
  2074.         theIcon := FirstHPaletteIcon;                                    {Start with using the first icon in this palette        }
  2075.         for theButton := HPaletteMinButton to HPaletteMaxButton do    {Cycle through all buttons in this palette…        }
  2076.             begin                                                        {                                                }
  2077.                                                                     {Determine number of picture buttons per row    }
  2078.                 ButtonsPerRow := (HPaletteMaxButton - HPaletteMinButton + 1) div 2;    {    (with two rows on this palette).    }
  2079.                 if theButton <= ButtonsPerRow then                        {Calculate the button's relative number in this    }
  2080.                     ButtonInRow := theButton                                {    row (i.e. the first button in this row, second,    }
  2081.                 else                                                        {    third, etc.)  This number is used to calculate    }
  2082.                     ButtonInRow := theButton - ButtonsPerRow;                {    horizontal button spacing.                    }
  2083.                                                                     {Horizontally, each button is 24 pixels apart        }
  2084.                                                                     {    from the previous one.  There are borders at    }
  2085.                                                                     {    the end of the 4th, 9th and 10th button, so    }
  2086.                                                                     {    add an extra 2 pixels between those        }
  2087.                                                                     {    buttons…                                    }
  2088.                 thePoint.h := (ButtonInRow - 1) * 24 + (2 * ord(ButtonInRow > 4)) + (2 * ord(ButtonInRow > 9)) + (2 * ord(ButtonInRow > 10)) - 1;
  2089.                 thePoint.v := ord(theButton > ButtonsPerRow) * 20 - 1;        {Half of the buttons fit on the top row, and the    }
  2090.                                                                     {    second half of them fit on the bottom row.    }
  2091.                                                                     {    The bottom row is 20 pixels lower than the    }
  2092.                                                                     {    first.                                        }
  2093.                                                                     {Create the picture button…                    }
  2094.                 NewPictButton(theButton, thePoint.h, thePoint.v, theIcon, SmallButtonSpec, enabled, notSelected, 0, 0, 0);
  2095.                 theIcon := theIcon + 1;                                        {Increment the icon for the next picture button    }
  2096.             end                                                            {                                                }
  2097.     end;                                                                {                                                }
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108. {  R e s p o n s e s   t o   E v e n t s : =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =    }
  2109. {    The following routines are invoked in response to events that were detected in the main event loop.                }
  2110.  
  2111.  
  2112. { U s e r   C l i c k e d   I n a c t i v e   W i n d o w : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -     }
  2113. {    This routine is called in response to a "doChgWindow" event.  Note that clicking between the active window        }
  2114. {    and a desk accessory, or between two desk accessories does not generate a doChgWindow event.                }
  2115. {        A doChgWindow event is generated only when the user tries to activate an inactive window belonging to        }
  2116. {    your application.  In a full featured application, you may want to validate the active editing field and perform any    }
  2117. {    other verifications before activating the window.                                                                }
  2118.     procedure ChangeWindow;
  2119.     begin
  2120.         ActivateWindow(Poll.Window);                                    {Activate the requested window                    }
  2121.     end;
  2122.  
  2123.  
  2124. { C h o o s e   A   M e n u : -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -    }
  2125. {    This routine is called in response to a "doMenu" event.  A doMenu event indicates that the user selected a menu    }
  2126. {    or typed a Command-key equivalent for a menu.  Note that a doMenu event is not generated if a desk            }
  2127. {    accessory's menu is selected.  The Edit menu's Undo, Cut, Copy, Paste, and Clear items automatically interact    }
  2128. {    with the active editing field without you having to do anything.                                                    }
  2129.     procedure MenuSelection;
  2130.         var
  2131.             theButton: integer;                                            {Button that was clicked in a Dynamic Alert        }
  2132.     begin
  2133.         case Poll.Menu.Num of
  2134.             ApplMenu:                                                    { A p p l e  M e n u :    -    -    -    -    -    -    -    }
  2135.                                                                     {The only item in the Apple menu that generates    }
  2136.                                                                     {    an event is the "About…" item.  All we do is    }
  2137.                                                                     {    display a Dynamic Alert box…                }
  2138.                 theButton := AlertBox(NoIcon, concat('T o o l s   P l u s   D e m o   A p p l i c a t i o n', ReturnKey, ReturnKey, 'Water’s Edge Software', ReturnKey, 'PO Box 70022', ReturnKey, '2441 Lakeshore Road West', ReturnKey, 'Oakville, Ontario', ReturnKey, 'Canada, L6L 6M9', ReturnKey, ReturnKey, '(416) 219-5628', ReturnKey, ReturnKey, '(Click this window to continue)'), NoButtonAlert);
  2139.  
  2140.  
  2141.             FileMenu:                                                     { F i l e   M e n u :    -    -    -    -    -    -    -    }
  2142.                 case Poll.Menu.Item of                                    {Determine the item selected within this menu…    }
  2143.                     CloseItem:                                                 { Close…                                        }
  2144.                         if FirstStdWindowNumber <> 0 then                    {If a standard window is open…                    }
  2145.                             CloseTheWindow(FirstStdWindowNumber)            {    close the front most standard window.        }
  2146.                         else if FirstPaletteNumber <> 0 then                    {If a flating palette is open…                    }
  2147.                             CloseTheWindow(FirstPaletteNumber);                {    close the front most palette.                }
  2148.  
  2149.                     QuitItem:                                                 { Quit…                                            }
  2150.                         ExitTheDemo := true;                                    {    set the 'exit the demo' flag to true to indicate}
  2151.                 end;                                                        {    we're ready to return to the Finder.            }
  2152.  
  2153.  
  2154.             DemosMenu:                                                    { D e m o s   M e n u :    -    -    -    -    -    -    }
  2155.                 begin                                                        {When selecting an item from the Demos menu,    }
  2156.                                                                     {    it means 'activate this demo window' if the    }
  2157.                                                                     {    window is already open, and 'open this demo}
  2158.                                                                     {    window' if it isn't open.                        }
  2159.  
  2160.                     if Poll.Menu.Item = ToolBarItem then                    {If user selected the Hide/Show Tool Bar item…    }
  2161.                         OpenDemoWindow9                                    {    Open or closes (hide) the Tool Bar            }
  2162.                     else                                                        {                                                }
  2163.                         begin                                                    {                                                }
  2164.                             ActivateWindow(Poll.Menu.Item);                        {Try to activate the window number that            }
  2165.                                                                     {    corresponds to the menu's item number.    }
  2166.                                                                     {    This will bring the window to the front.        }
  2167.                             if not WindowIsOpen(Poll.Menu.Item) then            {If the specified window is not open, it indicates    }
  2168.                                                                     {    the requested demo window is not open yet.    }
  2169.                                                                     {    So open the requested demo…                }
  2170.                                 case Poll.Menu.Item of                            {Determine the item selected within this menu    }
  2171.                                     1:                                                 {    and open the specified demo window.        }
  2172.                                         OpenDemoWindow1;                            {                                                }
  2173.                                     2:                                                 {                                                }
  2174.                                         OpenDemoWindow2;                            {                                                }
  2175.                                     3:                                                  {                                                }
  2176.                                         OpenDemoWindow3;                            {                                                }
  2177.                                     4:                                                  {                                                }
  2178.                                         OpenDemoWindow4;                            {                                                }
  2179.                                     5:                                                  {                                                }
  2180.                                         OpenDemoWindow5;                            {                                                }
  2181.                                     6:                                                  {                                                }
  2182.                                         OpenDemoWindow6;                            {                                                }
  2183.                                     7:                                                  {                                                }
  2184.                                         OpenDemoWindow7;                            {                                                }
  2185.                                     8:                                                  {                                                }
  2186.                                         OpenDemoWindow8;                            {                                                }
  2187.                                 end                                                {                                                }
  2188.                         end                                                    {                                                }
  2189.                 end;                                                        {                                                }
  2190.  
  2191.  
  2192.             PaletteDemoMenu:                                             { P a l e t t e   D e m o s   M e n u :    -    -    -    -     }
  2193.                 begin                                                        {The 'Palettes' menu is hierarchic, so you treat    }
  2194.                                                                     {    it like a separate pull-down menu.  When    }
  2195.                                                                     {    selecting an item from the Palettes Demos    }
  2196.                                                                     {    menu, it means 'activate this palette window'}
  2197.                                                                     {    if the window is already open, and 'open this    }
  2198.                                                                     {    palette window' if it isn't open.                }
  2199.                     ActivateWindow(Poll.Menu.Item + VerticalPalette - 1);    {Try to activate the palette number that            }
  2200.                                                                     {    corresponds to the menu's item number.    }
  2201.                                                                     {    This will bring the palette to the front.        }
  2202.                     if not WindowIsOpen(Poll.Menu.Item + VerticalPalette - 1) then    {If the specified palette is not open then    }
  2203.                                                                             {    display the palette…                }
  2204.                         case Poll.Menu.Item of                                {Determine the item selected within this menu    }
  2205.                             1:                                                     {    and open the specified palette window.        }
  2206.                                 OpenDemoWindow10;                                {                                                }
  2207.                             2:                                                     {                                                }
  2208.                                 OpenDemoWindow11;                                {                                                }
  2209.                         end                                                     {                                                }
  2210.                 end                                                        {                                                }
  2211.         end;
  2212.  
  2213.         if not ExitTheDemo then                                        {If the user has not quit the application…        }
  2214.             MenuHilite(0);                                                {    turn off the highlighted menu in the menu    }
  2215.                                                                     {    bar.  This shows the user that the            }
  2216.                                                                     {    application has responded to the menu        }
  2217.     end;                                                                {    selection.                                    }
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228. { P r e p a r a t i o n s : =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =    }
  2229. {    This routine does all the "set up" work for the demo, such as creating the menus and introducing the demo.        }
  2230. {    In a full-featured application, you would probably open documents that were double-clicked from the Finder.        }
  2231.     procedure PrepareTheDemo;
  2232.         const
  2233.             QuitAlert = 11700;                                            {Button definition for a 'Quit' Dynamic Alert        }
  2234.             SilentContinueAlert = -11500;                                    {Button definition for a "Continue" dynamic alert    }
  2235.                                                                     {    that doesn't beep the user.                    }
  2236.         var
  2237.             AltButton: integer;                                            {Button number clicked in an alert box            }
  2238.     begin
  2239.         SetNullTime(1, maxNullTime);                                    {Be a good neighbor to other applications by    }
  2240.                                                                     {    using fewer CPU cycles.                    }
  2241.         CursorShape(watchCursor);                                    {Change the cursor to a wrist watch                }
  2242.         MidiPort := ModemIcon;                                            {By default, select the modem port for a MIDI    }
  2243.         MidiSpeed := MidiOneMeg;                                        {    interface running at 1 MHz. (demo window 3)}
  2244.         ToolBarGray.red := integer(52428);                                {Define the toolbar color as a medium dark gray    }
  2245.         ToolBarGray.green := integer(52428);                            {                                                }
  2246.         ToolBarGray.blue := integer(52428);                            {                                                }
  2247.  
  2248.                                                                     { M e n u s :    -    -    -    -    -    -    -    -    -    }
  2249.         AppleMenu('About The Demo…');                                {Create the Apple menu with an "About…" item.    }
  2250.                                                                     {    You can now work with anything in the Apple}
  2251.                                                                     {    menu without having to write code for it!        }
  2252.         Menu(FileMenu, 0, enabled, 'File');                                {File menu:    create menu name (menu 1)            }
  2253.         Menu(FileMenu, 1, disabled, 'New/N');                            {            create 'New' item   (1st item)        }
  2254.         Menu(FileMenu, 2, disabled, 'Open/O');                            {            create 'Open' item   (2nd item)        }
  2255.         Menu(FileMenu, 3, disabled, 'Close/W');                            {            create 'Close' item   (3rd item)        }
  2256.         Menu(FileMenu, 4, disabled, mDividingLine);                    {            4th item is a dividing line            }
  2257.         Menu(FileMenu, 5, enabled, 'Quit/Q');                            {            create 'Quit' item (5th item)            }
  2258.         Menu(EditMenu, 0, enabled, 'Edit');                                {Edit menu:    create menu name (menu 2)            }
  2259.         Menu(EditMenu, 1, disabled, 'Undo/Z');                            {            The Undo, Cut, Copy, Paste, and    }
  2260.         Menu(EditMenu, 2, disabled, mDividingLine);                    {            Clear items are all disabled.  They    }
  2261.         Menu(EditMenu, 3, disabled, 'Cut/X');                            {            are automatically enabled as        }
  2262.         Menu(EditMenu, 4, disabled, 'Copy/C');                            {            required when working with editing    }
  2263.         Menu(EditMenu, 5, disabled, 'Paste/V');                        {            fields.  Your application can also    }
  2264.         Menu(EditMenu, 6, disabled, 'Clear');                            {            manually enable/disable these items}
  2265.         Menu(EditMenu, 7, disabled, mDividingLine);                    {            when working with other objects        }
  2266.         Menu(EditMenu, 8, disabled, 'Show Clipboard…');                {            such as graphics.                    }
  2267.                                                                     {                The Edit menu is needed for        }
  2268.                                                                     {            desk accessories and editing fields.}
  2269.                                                                     {            More items can be added to the Edit    }
  2270.                                                                     {            menu, and your application has full    }
  2271.                                                                     {            control of these items.                }
  2272.         Menu(DemosMenu, 0, enabled, 'Demos');                                {Demos:    The 'Demos' menu lets you    }
  2273.         Menu(DemosMenu, 1, enabled, 'Lists, Buttons and Cursor Zones/1');    {            open any of the windows    }
  2274.         Menu(DemosMenu, 2, enabled, 'Fields, Zooming and Scroll Bars/2');        {            that were created to        }
  2275.         Menu(DemosMenu, 3, enabled, 'Icons and Cursor Zones/3');            {            demonstrate a few of Tools    }
  2276.         Menu(DemosMenu, 4, enabled, 'Cursor Animation/4');                    {            Plus's features.            }
  2277.         Menu(DemosMenu, 5, enabled, 'Color Drawing and Multiple Monitors/5');    {                                        }
  2278.         Menu(DemosMenu, 6, enabled, 'Dynamic Alert Boxes/6');                {                                        }
  2279.         Menu(DemosMenu, 7, enabled, 'Pop-Up Menus/7');                        {                                        }
  2280.         Menu(DemosMenu, 8, enabled, 'Picture Buttons/8');                    {                                        }
  2281.         Menu(DemosMenu, 9, disabled, mDividingLine);                            {                                        }
  2282.         Menu(DemosMenu, 10, enabled, 'Show Tool Bar');                        {                                        }
  2283.         Menu(DemosMenu, 11, enabled, 'Floating Palettes (Windoids)');    {This item will become an hierarchic menu        }
  2284.         Menu(PaletteDemoMenu, 1, enabled, 'Vertical Orientation');        {Create an hierarchic menu by defining the        }
  2285.         Menu(PaletteDemoMenu, 2, enabled, 'Horizontal Orientation');    {    menu's items.                                }
  2286.         AttachMenu(DemosMenu, 11, PaletteDemoMenu);                {Attach the hierarchic 'palettes' menu to the        }
  2287.                                                                     {    11th item in the 'Demos' pull-down menu.    }
  2288.         UpdateMenuBar;                                                {Draw the menu bar with all its menu names        }
  2289.  
  2290.                                                                     { E d i t i n g   F i e l d s :    -    -    -    -    -    -    }
  2291.         hField1 := Str30Handle(NewStrHandle(30));                        {Allocate memory for the editing fields' strings.    }
  2292.         hField2 := NewStrHandle(255);                                    {    Tools Plus fields reference their related        }
  2293.         hField3 := NewStrHandle(255);                                    {    string by this handle.                        }
  2294.  
  2295.                                                                     {Display an alert that tells the user how to use    }
  2296.                                                                     {    the demo…                                    }
  2297.         AltButton := AlertBox(WatersEdgeLogo, concat('Welcome to the Tools Plus demo.', ReturnKey, ReturnKey, 'Use the “Demos” menu to explore each of the demos prepared for you.  Feel free to play around with the various objects.', ReturnKey, ReturnKey, 'Click “Continue” to start the first demo.'), SilentContinueAlert);
  2298.         OpenDemoWindow1;                                            {Open the first demo window                    }
  2299.         ResetCursor;                                                    {Get rid of the wrist watch cursor by resetting it    }
  2300.                                                                     {    to its proper shape (Tools Plus figures out    }
  2301.                                                                     {    its proper shape depending on where it is on    }
  2302.     end;                                                                {    the screen).                                }
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313. { M a i n   P r o g r a m : =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =    }
  2314. {    The main program demonstrates the detection of, and response to events.  Tools Plus events are more usable    }
  2315. {    than those obtained from The Event Manager.                                                                    }
  2316. begin
  2317.     if not InitToolsPlus(0, 12, UseColor) then                        {Initialize Tools Plus with 0 extra handle blocks    }
  2318.         ExitToShell;                                                    {    and a maximum of 11 open windows.  Use    }
  2319.                                                                     {    Color QuickDraw if it’s available.  If            }
  2320.                                                                     {    initialization fails, return to the Finder.        }
  2321.     PrepareTheDemo;                                                {Prepare the demo by creating the menus and    }
  2322.                                                                     {    opening a sample window.                    }
  2323.  
  2324.     ExitTheDemo := false;                                            {The demo is not over yet                        }
  2325.     while not ExitTheDemo do                                        {Keep polling for an event until the Quit item is    }
  2326.                                                                     {    selected in the File menu…                    }
  2327.         if PollSystem(Poll) then                                        {If an event has been detected…                }
  2328.             case Poll.What of                                            {Determine what kind of event has occurred…    }
  2329.                 doMenu:                                                     {User selected a menu item…                    }
  2330.                     MenuSelection;                                            {    execute that menu item.                    }
  2331.                 doChgWindow:                                                 {User clicked on an inactive window…            }
  2332.                     ChangeWindow;                                             {    activate the window the user clicked.        }
  2333.                 doRefresh:                                                     {A window needs to be refreshed…                }
  2334.                     RefreshWindow;                                            {    redraw the specified window.                }
  2335.                 doGoAway:                                                 {User clicked a window's 'close box'…            }
  2336.                     CloseTheWindow(Poll.Window);                            {    close the affected window.                    }
  2337.                                                                     {The user has clicked a button, typed a key,    }
  2338.                                                                     {    clicked in an inactive field, used a scroll        }
  2339.                                                                     {    bar, clicked a line in a list box, used a Pop-    }
  2340.                                                                     {    Up Menu, or clicked in the window (not on an}
  2341.                                                                     {    object)…                                    }
  2342.                 doButton, doPictButton, doKeyDown, doAutoKey, doClickField, doScrollBar, doListBox, doPopUpMenu, doClick: 
  2343.                     if Poll.Window <> none then                                {If the event is applied to an open window…        }
  2344.                         begin                                                    {    (ignore events if no window is open)            }
  2345.                             CurrentWindow(Poll.Window);                            {Make the affected window current.  It will be the}
  2346.                                                                     {    target of actions that are made in response    }
  2347.                                                                     {    to the user's activity in the affected window.}
  2348.                             case Poll.Window of                                    {Determine which window is affected and call the}
  2349.                                 1:                                                     {    appropriate routine to respond to the user's     }
  2350.                                     ActionInWindow1;                                {    activity (ie: call a window-handler routine).    }
  2351.                                 2:                                                     {                                                }
  2352.                                     ActionInWindow2;                                {                                                }
  2353.                                 3:                                                     {                                                }
  2354.                                     ActionInWindow3;                                {                                                }
  2355.                                 4:                                                     {                                                }
  2356.                                     ActionInWindow4;                                {                                                }
  2357.                                 5:                                                     {                                                }
  2358.                                     ActionInWindow5;                                {                                                }
  2359.                                 6:                                                     {                                                }
  2360.                                     ActionInWindow6;                                {                                                }
  2361.                                 7:                                                     {                                                }
  2362.                                     ActionInWindow7;                                {                                                }
  2363.                                 8:                                                     {                                                }
  2364.                                     ActionInWindow8;                                {                                                }
  2365.                                 9:                                                     {                                                }
  2366.                                     ActionInWindow9;                                {                                                }
  2367.                                 10:                                                     {                                                }
  2368.                                     ActionInWindow10;                                {                                                }
  2369.                                 11:                                                     {                                                }
  2370.                                     ActionInWindow11;                                {                                                }
  2371.                             end                                                    {                                                }
  2372.                         end;                                                    {                                                }
  2373.                 otherwise                                                {All other events are ignored                    }
  2374.             end                                                            {                                                }
  2375.  
  2376.         else                                                            {If this demo was to perform on-going            }
  2377.             ;                                                                {    operations, perhaps even when suspended,}
  2378.                                                                     {    that code would go here.                    }
  2379.  
  2380.     CursorShape(watchCursor);                                        {Change the cursor to a wrist watch as the demo}
  2381.                                                                     {    quits to the Finder.  Visually, it looks more    }
  2382.                                                                     {    professional to 'look busy' while the            }
  2383. end.                                                                {    application quits.                            }